posix_fadvise64.c 1.0 KB

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