ioctl.c 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * ioctl() 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 <stdarg.h>
  11. #include <sys/ioctl.h>
  12. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  13. #include <sysdep-cancel.h>
  14. #else
  15. #define SINGLE_THREAD_P 1
  16. #endif
  17. libc_hidden_proto(ioctl)
  18. #define __NR___syscall_ioctl __NR_ioctl
  19. static __always_inline
  20. _syscall3(int, __syscall_ioctl, int, fd, unsigned long int, request, void *, arg)
  21. int ioctl(int fd, unsigned long int request, ...)
  22. {
  23. void *arg;
  24. va_list list;
  25. va_start(list, request);
  26. arg = va_arg(list, void *);
  27. va_end(list);
  28. if (SINGLE_THREAD_P)
  29. return __syscall_ioctl(fd, request, arg);
  30. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  31. int oldtype = LIBC_CANCEL_ASYNC ();
  32. int result = __syscall_ioctl(fd, request, arg);
  33. LIBC_CANCEL_RESET (oldtype);
  34. return result;
  35. #endif
  36. }
  37. libc_hidden_def(ioctl)