posix_fadvise64.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fadvise64() for MIPS uClibc
  4. * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
  5. *
  6. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  7. *
  8. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  9. */
  10. #include <_lfs_64.h>
  11. #include <sys/syscall.h>
  12. #include <bits/wordsize.h>
  13. /* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
  14. #if defined __NR_fadvise64 && __WORDSIZE == 32
  15. # include <fcntl.h>
  16. # include <endian.h>
  17. int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice)
  18. {
  19. INTERNAL_SYSCALL_DECL(err);
  20. # if _MIPS_SIM == _ABIO32
  21. int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
  22. __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
  23. __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
  24. advice);
  25. # else /* N32 || N64 */
  26. int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  27. # endif
  28. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  29. return INTERNAL_SYSCALL_ERRNO (ret, err);
  30. return 0;
  31. }
  32. #endif