posix_fadvise.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fadvise() for MIPS 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. int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  19. {
  20. /* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
  21. #ifdef __NR_fadvise64
  22. INTERNAL_SYSCALL_DECL(err);
  23. # if _MIPS_SIM == _ABIO32
  24. int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
  25. __LONG_LONG_PAIR ((long) (offset >> 31), (long) offset),
  26. __LONG_LONG_PAIR ((long) (len >> 31), (long) len),
  27. advice);
  28. # else /* N32 || N64 */
  29. int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  30. # endif
  31. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  32. return INTERNAL_SYSCALL_ERRNO (ret, err);
  33. return 0;
  34. #else
  35. return ENOSYS;
  36. #endif
  37. }