llseek.c 952 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 <unistd.h>
  10. #include <sys/types.h>
  11. #include <sys/syscall.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 && defined __UCLIBC_HAS_LFS__
  17. loff_t lseek64(int fd, loff_t offset, int whence)
  18. {
  19. loff_t result;
  20. return (loff_t)(INLINE_SYSCALL(_llseek, 5, fd, (off_t) (offset >> 32),
  21. (off_t) (offset & 0xffffffff), &result, whence) ?: result);
  22. }
  23. #else
  24. loff_t lseek64(int fd, loff_t offset, int whence)
  25. {
  26. return (loff_t)(lseek(fd, (off_t) (offset), whence));
  27. }
  28. #endif
  29. #ifndef __LINUXTHREADS_OLD__
  30. libc_hidden_def(lseek64)
  31. #else
  32. libc_hidden_weak(lseek64)
  33. strong_alias(lseek64,__libc_lseek64)
  34. #endif