llseek.c 959 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * llseek/lseek64 syscall for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <_lfs_64.h>
  9. #include <sys/syscall.h>
  10. #include <bits/wordsize.h>
  11. /* Newer kernel ports have llseek() instead of _llseek() */
  12. #if !defined __NR__llseek && defined __NR_llseek
  13. # define __NR__llseek __NR_llseek
  14. #endif
  15. #if defined __NR__llseek && __WORDSIZE == 32
  16. # include <unistd.h>
  17. # include <endian.h>
  18. # include <cancel.h>
  19. off64_t __NC(lseek64)(int fd, off64_t offset, int whence)
  20. {
  21. off64_t result;
  22. /* do we not need to handle the offset with __LONG_LONG_PAIR depending on endianness? */
  23. return (off64_t)INLINE_SYSCALL(_llseek, 5, fd, (off_t) OFF64_HI(offset),
  24. (off_t) OFF64_LO(offset), &result, whence) ?: result;
  25. }
  26. CANCELLABLE_SYSCALL(off64_t, lseek64, (int fd, off64_t offset, int whence), (fd, offset, whence))
  27. lt_libc_hidden(lseek64)
  28. #endif