posix_fadvise64.c 958 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fadvise64() for Xtensa uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. * Copyright (C) 2007 Tensilica Inc.
  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. #ifdef __NR_fadvise64_64
  22. INTERNAL_SYSCALL_DECL (err);
  23. int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
  24. __LONG_LONG_PAIR ((long) (offset >> 32),
  25. (long) offset),
  26. __LONG_LONG_PAIR ((long) (len >> 32),
  27. (long) len));
  28. if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
  29. return 0;
  30. return INTERNAL_SYSCALL_ERRNO (ret, err);
  31. #else
  32. return ENOSYS;
  33. #endif
  34. }
  35. #endif /* __UCLIBC_HAS_LFS__ */