lseek.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * lseek() 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 <sys/syscall.h>
  10. #include <unistd.h>
  11. #include <cancel.h>
  12. #ifdef __NR_lseek
  13. # define __NR___lseek_nocancel __NR_lseek
  14. _syscall3(off_t, __NC(lseek), int, fd, off_t, offset, int, whence)
  15. #else
  16. # include <errno.h>
  17. off_t __NC(lseek)(int fd, off_t offset attribute_unused, int whence)
  18. {
  19. if (fd < 0) {
  20. __set_errno(EBADF);
  21. return -1;
  22. }
  23. switch(whence) {
  24. case SEEK_SET:
  25. case SEEK_CUR:
  26. case SEEK_END:
  27. break;
  28. default:
  29. __set_errno(EINVAL);
  30. return -1;
  31. }
  32. __set_errno(ENOSYS);
  33. return -1;
  34. }
  35. #endif
  36. CANCELLABLE_SYSCALL(off_t, lseek, (int fd, off_t offset, int whence), (fd, offset, whence))
  37. lt_libc_hidden(lseek)
  38. #if defined __UCLIBC_HAS_LFS__ && (__WORDSIZE == 64 || (!defined __NR__llseek && !defined __NR_llseek))
  39. strong_alias_untyped(__NC(lseek),__NC(lseek64))
  40. strong_alias_untyped(lseek,lseek64)
  41. lt_strong_alias(lseek64)
  42. lt_libc_hidden(lseek64)
  43. #endif