posix_fadvise.c 762 B

1234567891011121314151617181920212223242526272829
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fadvise() 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 <sys/syscall.h>
  11. #include <fcntl.h>
  12. int posix_fadvise (int fd, off_t offset, off_t len, int advice)
  13. {
  14. #ifdef __NR_fadvise64_64
  15. INTERNAL_SYSCALL_DECL (err);
  16. int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
  17. __LONG_LONG_PAIR ((long) (offset >> 31),
  18. (long) offset),
  19. __LONG_LONG_PAIR ((long) (len >> 31),
  20. (long) len));
  21. if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
  22. return 0;
  23. return INTERNAL_SYSCALL_ERRNO (ret, err);
  24. #else
  25. return ENOSYS;
  26. #endif
  27. }