posix_fadvise.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 <sys/syscall.h>
  11. /* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
  12. #ifdef __NR_fadvise64
  13. # include <fcntl.h>
  14. # include <endian.h>
  15. # include <bits/wordsize.h>
  16. int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  17. {
  18. INTERNAL_SYSCALL_DECL(err);
  19. # if _MIPS_SIM == _ABIO32
  20. int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
  21. __LONG_LONG_PAIR ((long) (offset >> 31), (long) offset),
  22. __LONG_LONG_PAIR ((long) (len >> 31), (long) len),
  23. advice);
  24. # else /* N32 || N64 */
  25. int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
  26. # endif
  27. if (INTERNAL_SYSCALL_ERROR_P (ret, err))
  28. return INTERNAL_SYSCALL_ERRNO (ret, err);
  29. return 0;
  30. }
  31. # if __WORDSIZE == 64
  32. strong_alias(posix_fadvise,posix_fadvise64)
  33. # endif
  34. #endif