posix_fadvise.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * posix_fadvise() for MIPS uClibc
  3. * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. /* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
  11. #ifdef __NR_fadvise64
  12. # include <fcntl.h>
  13. # include <endian.h>
  14. # include <bits/wordsize.h>
  15. int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  16. {
  17. INTERNAL_SYSCALL_DECL(err);
  18. # if _MIPS_SIM == _ABIO32
  19. int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
  20. __LONG_LONG_PAIR ((long) (offset >> 31), (long) offset),
  21. __LONG_LONG_PAIR ((long) (len >> 31), (long) len),
  22. advice);
  23. # else /* N32 || N64 */
  24. int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  25. # endif
  26. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  27. return INTERNAL_SYSCALL_ERRNO (ret, err);
  28. return 0;
  29. }
  30. # if __WORDSIZE == 64
  31. strong_alias(posix_fadvise,posix_fadvise64)
  32. # endif
  33. #endif