llseek.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #define _GNU_SOURCE
  10. #define _LARGEFILE64_SOURCE
  11. #include <features.h>
  12. #undef __OPTIMIZE__
  13. /* We absolutely do _NOT_ want interfaces silently
  14. * renamed under us or very bad things will happen... */
  15. #ifdef __USE_FILE_OFFSET64
  16. # undef __USE_FILE_OFFSET64
  17. #endif
  18. #include <errno.h>
  19. #include <unistd.h>
  20. #include <sys/types.h>
  21. #include <sys/syscall.h>
  22. #if defined __NR__llseek && defined __UCLIBC_HAS_LFS__
  23. # ifndef INLINE_SYSCALL
  24. # define INLINE_SYSCALL(name, nr, args...) __syscall_llseek (args)
  25. # define __NR___syscall_llseek __NR__llseek
  26. static inline _syscall5(int, __syscall_llseek, int, fd, off_t, offset_hi,
  27. off_t, offset_lo, loff_t *, result, int, whence);
  28. # endif
  29. loff_t __libc_lseek64(int fd, loff_t offset, int whence)
  30. {
  31. loff_t result;
  32. return(loff_t)(INLINE_SYSCALL (_llseek, 5, fd, (off_t) (offset >> 32),
  33. (off_t) (offset & 0xffffffff), &result, whence) ?: result);
  34. }
  35. #else
  36. extern __off_t __libc_lseek(int fildes, off_t offset, int whence);
  37. libc_hidden_proto(__libc_lseek)
  38. loff_t __libc_lseek64(int fd, loff_t offset, int whence)
  39. {
  40. return(loff_t)(__libc_lseek(fd, (off_t) (offset), whence));
  41. }
  42. #endif
  43. libc_hidden_proto(lseek64)
  44. strong_alias(__libc_lseek64,lseek64)
  45. libc_hidden_def(lseek64)
  46. //strong_alias(__libc_lseek64,_llseek)