posix_fadvise64.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /* Was named __libc_posix_fadvise64 for some inexplicable reason.
  21. ** google says only uclibc has *__libc*_posix_fadviseXXX,
  22. ** so it cannot be compat with anything.
  23. **
  24. ** Remove this comment and one at the end after 0.9.31
  25. */
  26. /* This is for the ARM version of fadvise64_64 which swaps the params
  27. * about to avoid having ABI compat issues
  28. */
  29. #define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
  30. int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
  31. {
  32. INTERNAL_SYSCALL_DECL (err);
  33. int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
  34. __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
  35. __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
  36. if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
  37. return 0;
  38. if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
  39. return INTERNAL_SYSCALL_ERRNO (ret, err);
  40. return 0;
  41. }
  42. /* weak_alias(__libc_posix_fadvise64, posix_fadvise64); */
  43. #else
  44. int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
  45. {
  46. return ENOSYS;
  47. }
  48. #endif
  49. #endif