llseek.c 933 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 <unistd.h>
  12. #include <stdint.h>
  13. /* Newer kernel ports have llseek() instead of _llseek() */
  14. #if !defined __NR__llseek && defined __NR_llseek
  15. # define __NR__llseek __NR_llseek
  16. #endif
  17. #ifdef __NR__llseek
  18. off64_t lseek64(int fd, off64_t offset, int whence)
  19. {
  20. off64_t result;
  21. return (off64_t)INLINE_SYSCALL(_llseek, 5, fd, (off_t) (offset >> 32),
  22. (off_t) (offset & 0xffffffff), &result, whence) ?: result;
  23. }
  24. #else
  25. off64_t lseek64(int fd, off64_t offset, int whence)
  26. {
  27. return (off64_t)lseek(fd, (off_t) (offset), whence);
  28. }
  29. #endif
  30. #ifndef __LINUXTHREADS_OLD__
  31. libc_hidden_def(lseek64)
  32. #else
  33. libc_hidden_weak(lseek64)
  34. strong_alias(lseek64,__libc_lseek64)
  35. #endif