summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2011-04-21 21:55:48 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-15 14:00:40 +0200
commit6c7c4fb8e1ff2d7d170af3f50acd4cdc30f608f6 (patch)
treedf06b67a79e74e9c1b2612edc859bf25a61676e9 /libc/sysdeps/linux/common
parente4b5997fc1cea7eeaad155aad02b8b1997143874 (diff)
select: adapt cancelation to use cancel.h
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/select.c75
1 files changed, 21 insertions, 54 deletions
diff --git a/libc/sysdeps/linux/common/select.c b/libc/sysdeps/linux/common/select.c
index 029fb08a0..c13bd0418 100644
--- a/libc/sysdeps/linux/common/select.c
+++ b/libc/sysdeps/linux/common/select.c
@@ -9,27 +9,24 @@
#include <sys/syscall.h>
#include <sys/select.h>
-#include <stdint.h>
+#include <cancel.h>
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <sysdep-cancel.h>
-#else
-#define SINGLE_THREAD_P 1
+#ifdef __NR__newselect
+# undef __NR_select
+# define __NR_select __NR__newselect
#endif
-#define USEC_PER_SEC 1000000L
-
-extern __typeof(select) __libc_select;
-
-#if !defined(__NR__newselect) && !defined(__NR_select) && defined __USE_XOPEN2K
-# define __NR___libc_pselect6 __NR_pselect6
-static _syscall6(int, __libc_pselect6, int, n, fd_set *, readfds, fd_set *, writefds,
- fd_set *, exceptfds, const struct timespec *, timeout,
- const sigset_t *, sigmask)
+#if !defined __NR_select && defined __NR_pselect6
+# include <stdint.h>
+# define USEC_PER_SEC 1000000L
+#endif
-int __libc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- struct timeval *timeout)
+int __NC(select)(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ struct timeval *timeout)
{
+#ifdef __NR_select
+ return INLINE_SYSCALL(select, 5, n, readfds, writefds, exceptfds, timeout);
+#elif defined __NR_pselect6
struct timespec _ts, *ts = 0;
if (timeout) {
uint32_t usec;
@@ -51,44 +48,14 @@ int __libc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
ts = &_ts;
}
-
- if (SINGLE_THREAD_P)
- return __libc_pselect6(n, readfds, writefds, exceptfds, ts, 0);
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- int result = __libc_pselect6(n, readfds, writefds, exceptfds, ts, 0);
- LIBC_CANCEL_RESET (oldtype);
- return result;
-#endif
-
-}
-
-#else
-
-#ifdef __NR__newselect
-# define __NR___syscall_select __NR__newselect
-#else
-# define __NR___syscall_select __NR_select
-#endif
-
-static _syscall5(int, __syscall_select, int, n, fd_set *, readfds,
- fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout);
-
-int __libc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- struct timeval *timeout)
-{
- if (SINGLE_THREAD_P)
- return __syscall_select(n, readfds, writefds, exceptfds, timeout);
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- int result = __syscall_select(n, readfds, writefds, exceptfds, timeout);
- LIBC_CANCEL_RESET (oldtype);
- return result;
+ return INLINE_SYSCALL(pselect6, 6, n, readfds, writefds, exceptfds, ts, 0);
#endif
}
-
+/* we should guard it, but we need it in other files, so let it fail
+ * if we miss any of the syscalls */
+#if 1 /*defined __NR_select || defined __NR_pselect6*/
+CANCELLABLE_SYSCALL(int, select, (int n, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout),
+ (n, readfds, writefds, exceptfds, timeout))
+lt_libc_hidden(select)
#endif
-
-weak_alias(__libc_select,select)
-libc_hidden_weak(select)