summaryrefslogtreecommitdiff
path: root/tests/test-select.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-07-05 14:46:08 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-07-06 00:44:19 -0700
commit623de7351499ed8225783a69e441520a15a65a52 (patch)
treeb462a9e13b0926b176f2519a85b029eed8d03fc7 /tests/test-select.c
parent498a60f86bdaf01a0e20495013a3479551e04e6d (diff)
downloadgnulib-623de7351499ed8225783a69e441520a15a65a52.tar.gz
test-pselect: new module
* modules/pselect-tests, tests/test-pselect.c: New files. * tests/test-select.c, tests/test-sys_select-c++.cc: If TEST_PSELECT is defined, test pselect instead of testing select.
Diffstat (limited to 'tests/test-select.c')
-rw-r--r--tests/test-select.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-select.c b/tests/test-select.c
index 5c1532015d..9e927f81d6 100644
--- a/tests/test-select.c
+++ b/tests/test-select.c
@@ -21,8 +21,16 @@
#include <sys/select.h>
#include "signature.h"
+
+#ifdef TEST_PSELECT
+SIGNATURE_CHECK (pselect, int,
+ (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+ struct timespec const *restrict, const sigset_t *restrict));
+#else
SIGNATURE_CHECK (select, int, (int, fd_set *, fd_set *, fd_set *,
struct timeval *));
+#endif
+
/* The following may be macros without underlying functions, so only
check signature if they are not macros. */
#ifndef FD_CLR
@@ -190,7 +198,20 @@ do_select (int fd, int ev, struct timeval *timeout)
FD_SET (fd, &wfds);
if (ev & SEL_EXC)
FD_SET (fd, &xfds);
+#ifdef TEST_PSELECT
+ {
+ struct timespec ts, *pts = NULL;
+ if (timeout)
+ {
+ ts.tv_sec = timeout->tv_sec;
+ ts.tv_nsec = timeout->tv_usec * 1000;
+ pts = &ts;
+ }
+ r = pselect (fd + 1, &rfds, &wfds, &xfds, pts, NULL);
+ }
+#else
r = select (fd + 1, &rfds, &wfds, &xfds, timeout);
+#endif
if (r < 0)
return r;