posix_fadvise.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifdef __NR_fadvise64
  12. # include <fcntl.h>
  13. # include <endian.h>
  14. # include <bits/wordsize.h>
  15. int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  16. {
  17. int ret;
  18. INTERNAL_SYSCALL_DECL(err);
  19. # if __WORDSIZE == 64
  20. ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  21. # else
  22. # ifdef __powerpc__
  23. ret = INTERNAL_SYSCALL(fadvise64, err, 6, fd, /*unused*/0,
  24. # else
  25. ret = INTERNAL_SYSCALL(fadvise64, err, 5, fd,
  26. # endif
  27. __LONG_LONG_PAIR (offset >> 31, offset), len, advice);
  28. # endif
  29. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  30. return INTERNAL_SYSCALL_ERRNO (ret, err);
  31. return 0;
  32. }
  33. # if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
  34. strong_alias(posix_fadvise,posix_fadvise64)
  35. # endif
  36. #endif