posix_fadvise64.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fadvise64() for ARM 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. #if defined __NR_arm_fadvise64_64
  20. /* This is for the ARM version of fadvise64_64 which swaps the params
  21. * about to avoid having ABI compat issues
  22. */
  23. #define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
  24. int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
  25. {
  26. INTERNAL_SYSCALL_DECL (err);
  27. int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
  28. __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
  29. __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
  30. if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
  31. return 0;
  32. if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
  33. return INTERNAL_SYSCALL_ERRNO (ret, err);
  34. return 0;
  35. }
  36. weak_alias(__libc_posix_fadvise64, posix_fadvise64);
  37. #else
  38. int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
  39. {
  40. return ENOSYS;
  41. }
  42. #endif
  43. #endif