posix_fadvise64.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <features.h>
  11. #include <unistd.h>
  12. #include <errno.h>
  13. #include <endian.h>
  14. #include <stdint.h>
  15. #include <sys/types.h>
  16. #include <sys/syscall.h>
  17. #include <fcntl.h>
  18. #ifdef __UCLIBC_HAS_LFS__
  19. int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
  20. {
  21. /* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
  22. #ifdef __NR_fadvise64
  23. INTERNAL_SYSCALL_DECL(err);
  24. # if _MIPS_SIM == _MIPS_SIM_ABI32
  25. int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
  26. __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
  27. __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
  28. advice);
  29. # else /* N32 || N64 */
  30. int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  31. # endif
  32. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  33. return INTERNAL_SYSCALL_ERRNO (ret, err);
  34. return 0;
  35. #else
  36. return ENOSYS;
  37. #endif
  38. }
  39. #endif /* __UCLIBC_HAS_LFS__ */