posix_fadvise.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fadvise() for 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 <sys/syscall.h>
  11. #if defined(__NR_fadvise64) || defined(__NR_arm_fadvise64_64)
  12. # include <fcntl.h>
  13. # include <endian.h>
  14. # include <bits/wordsize.h>
  15. # ifdef __NR_arm_fadvise64_64
  16. int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
  17. # endif
  18. int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  19. {
  20. # ifdef __NR_arm_fadvise64_64
  21. return posix_fadvise64(fd, offset, len, advice);
  22. # else
  23. int ret;
  24. INTERNAL_SYSCALL_DECL(err);
  25. # if __WORDSIZE == 64
  26. ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  27. # else
  28. # if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
  29. ret = INTERNAL_SYSCALL(fadvise64, err, 6, fd, /*unused*/0,
  30. # else
  31. ret = INTERNAL_SYSCALL(fadvise64, err, 5, fd,
  32. # endif
  33. OFF_HI_LO (offset), len, advice);
  34. # endif
  35. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  36. return INTERNAL_SYSCALL_ERRNO (ret, err);
  37. return 0;
  38. # endif
  39. }
  40. # if defined __UCLIBC_HAS_LFS__ && ((!defined __NR_fadvise64_64 && !defined __NR_arm_fadvise64_64) || __WORDSIZE == 64)
  41. strong_alias(posix_fadvise,posix_fadvise64)
  42. # endif
  43. #endif