llseek.c 984 B

1234567891011121314151617181920212223242526272829303132
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * llseek/lseek64 syscall for uClibc
  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 <_lfs_64.h>
  10. #include <sys/syscall.h>
  11. #include <bits/wordsize.h>
  12. /* Newer kernel ports have llseek() instead of _llseek() */
  13. #if !defined __NR__llseek && defined __NR_llseek
  14. # define __NR__llseek __NR_llseek
  15. #endif
  16. #if defined __NR__llseek && __WORDSIZE == 32
  17. # include <unistd.h>
  18. # include <endian.h>
  19. # include <cancel.h>
  20. off64_t __NC(lseek64)(int fd, off64_t offset, int whence)
  21. {
  22. off64_t result;
  23. /* do we not need to handle the offset with __LONG_LONG_PAIR depending on endianness? */
  24. return (off64_t)INLINE_SYSCALL(_llseek, 5, fd, (off_t) OFF64_HI(offset),
  25. (off_t) OFF64_LO(offset), &result, whence) ?: result;
  26. }
  27. CANCELLABLE_SYSCALL(off64_t, lseek64, (int fd, off64_t offset, int whence), (fd, offset, whence))
  28. lt_libc_hidden(lseek64)
  29. #endif