yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 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 | |
| 10 | #include <sys/syscall.h> |
| 11 | #include <stdarg.h> |
| 12 | #include <sys/ioctl.h> |
| 13 | |
| 14 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 15 | #include <sysdep-cancel.h> |
| 16 | #else |
| 17 | #define SINGLE_THREAD_P 1 |
| 18 | #endif |
| 19 | |
| 20 | libc_hidden_proto(ioctl) |
| 21 | |
| 22 | #define __NR___syscall_ioctl __NR_ioctl |
| 23 | static __always_inline |
| 24 | _syscall3(int, __syscall_ioctl, int, fd, unsigned long int, request, void *, arg) |
| 25 | |
| 26 | int ioctl(int fd, unsigned long int request, ...) |
| 27 | { |
| 28 | void *arg; |
| 29 | va_list list; |
| 30 | |
| 31 | va_start(list, request); |
| 32 | arg = va_arg(list, void *); |
| 33 | |
| 34 | va_end(list); |
| 35 | |
| 36 | if (SINGLE_THREAD_P) |
| 37 | return __syscall_ioctl(fd, request, arg); |
| 38 | |
| 39 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 40 | int oldtype = LIBC_CANCEL_ASYNC (); |
| 41 | int result = __syscall_ioctl(fd, request, arg); |
| 42 | LIBC_CANCEL_RESET (oldtype); |
| 43 | return result; |
| 44 | #endif |
| 45 | } |
| 46 | libc_hidden_def(ioctl) |