__syscall_fcntl.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * __syscall_fcntl() for uClibc
  4. *
  5. * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
  6. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  7. *
  8. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  9. */
  10. #include <sys/syscall.h>
  11. #include <stdarg.h>
  12. #include <cancel.h> /* Must come before <fcntl.h>. */
  13. #include <fcntl.h>
  14. #include <bits/wordsize.h>
  15. int __NC(fcntl)(int fd, int cmd, long arg)
  16. {
  17. #if __WORDSIZE == 32
  18. if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
  19. # if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
  20. return __NC(fcntl64)(fd, cmd, arg);
  21. # else
  22. __set_errno(ENOSYS);
  23. return -1;
  24. # endif
  25. }
  26. #endif
  27. return INLINE_SYSCALL(fcntl, 3, fd, cmd, arg);
  28. }
  29. int fcntl(int fd, int cmd, ...)
  30. {
  31. va_list ap;
  32. long arg;
  33. va_start (ap, cmd);
  34. arg = va_arg (ap, long);
  35. va_end (ap);
  36. if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
  37. return __NC(fcntl)(fd, cmd, arg);
  38. #ifdef __NEW_THREADS
  39. int oldtype = LIBC_CANCEL_ASYNC ();
  40. int result = __NC(fcntl)(fd, cmd, arg);
  41. LIBC_CANCEL_RESET (oldtype);
  42. return result;
  43. #endif
  44. }
  45. lt_strong_alias(fcntl)
  46. lt_libc_hidden(fcntl)
  47. #if defined __UCLIBC_HAS_LFS__ && !defined __NR_fcntl64 && __WORDSIZE == 32
  48. strong_alias_untyped(fcntl,fcntl64)
  49. lt_strong_alias(fcntl64)
  50. lt_libc_hidden(fcntl64)
  51. #endif