diff options
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/pselect.c | 35 | ||||
-rw-r--r-- | sysdeps/generic/sysdep-cancel.h | 5 |
2 files changed, 32 insertions, 8 deletions
diff --git a/sysdeps/generic/pselect.c b/sysdeps/generic/pselect.c index 6aa60e8e72..e090d6e526 100644 --- a/sysdeps/generic/pselect.c +++ b/sysdeps/generic/pselect.c @@ -22,6 +22,7 @@ #include <stddef.h> /* For NULL. */ #include <sys/time.h> #include <sys/select.h> +#include <sysdep-cancel.h> /* Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS @@ -29,14 +30,9 @@ after waiting the interval specified therein. Additionally set the sigmask SIGMASK for this call. Returns the number of ready descriptors, or -1 for errors. */ -int -__pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask) - int nfds; - fd_set *readfds; - fd_set *writefds; - fd_set *exceptfds; - const struct timespec *timeout; - const sigset_t *sigmask; +static int +do_pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + const struct timespec *timeout, const sigset_t *sigmask) { struct timeval tval; int retval; @@ -62,5 +58,28 @@ __pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask) return retval; } + + +int +__pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask) + int nfds; + fd_set *readfds; + fd_set *writefds; + fd_set *exceptfds; + const struct timespec *timeout; + const sigset_t *sigmask; +{ + if (SINGLE_THREAD_P) + return do_pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask); + + int oldtype = LIBC_CANCEL_ASYNC (); + + int result = do_pselect (nfds, readfds, writefds, exceptfds, timeout, + sigmask); + + LIBC_CANCEL_RESET (oldtype); + + return result; +} weak_alias (__pselect, pselect) strong_alias (__pselect, __libc_pselect) diff --git a/sysdeps/generic/sysdep-cancel.h b/sysdeps/generic/sysdep-cancel.h index 0eca1e927c..f065e6e437 100644 --- a/sysdeps/generic/sysdep-cancel.h +++ b/sysdeps/generic/sysdep-cancel.h @@ -1 +1,6 @@ #include <sysdep.h> + +/* No multi-thread handling enabled. */ +#define SINGLE_THREAD_P (1) +#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ +#define LIBC_CANCEL_RESET(val) /* Nothing. */ |