[git commit future] select: adapt cancelation to use cancel.h

Peter S. Mazinger ps.m at gmx.net
Wed Apr 20 10:50:38 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=5aa1448caef9a897b916d2d3679ef6c433f4004c
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 include/sys/select.h               |    3 +
 libc/sysdeps/linux/common/select.c |   75 ++++++++++--------------------------
 2 files changed, 24 insertions(+), 54 deletions(-)

diff --git a/include/sys/select.h b/include/sys/select.h
index 6ffe4e2..5436e20 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -110,7 +110,10 @@ extern int select (int __nfds, fd_set *__restrict __readfds,
 		   fd_set *__restrict __writefds,
 		   fd_set *__restrict __exceptfds,
 		   struct timeval *__restrict __timeout);
+#ifdef _LIBC
+extern __typeof(select) __select_nocancel attribute_hidden;
 libc_hidden_proto(select)
+#endif
 
 #ifdef __USE_XOPEN2K
 /* Same as above only that the TIMEOUT value is given with higher
diff --git a/libc/sysdeps/linux/common/select.c b/libc/sysdeps/linux/common/select.c
index 029fb08..c13bd04 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)
-- 
1.7.3.4



More information about the uClibc-cvs mailing list