Index: ossp-pkg/pth/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/pth/ChangeLog,v rcsdiff -q -kk '-r1.581' '-r1.582' -u '/v/ossp/cvs/ossp-pkg/pth/ChangeLog,v' 2>/dev/null --- ChangeLog 2002/10/25 11:53:28 1.581 +++ ChangeLog 2002/10/25 11:56:16 1.582 @@ -21,6 +21,10 @@ Changes between 1.4.1 and 1.5.0 (27-Jan-2002 to xx-Oct-2002) + *) Add a Pth variant of the new POSIX pselect(2) function, including + soft and hard syscall mapping support for it. + [Ralf S. Engelschall] + *) More POSIX compliance for pth_select() in case of invalid timeout values and invalid filedescriptors. [Ralf S. Engelschall] Index: ossp-pkg/pth/pth.h.in RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.h.in,v rcsdiff -q -kk '-r1.133' '-r1.134' -u '/v/ossp/cvs/ossp-pkg/pth/pth.h.in,v' 2>/dev/null --- pth.h.in 2002/10/23 14:04:00 1.133 +++ pth.h.in 2002/10/25 11:56:16 1.134 @@ -504,6 +504,7 @@ extern int pth_connect(int, const struct sockaddr *, socklen_t); extern int pth_accept(int, struct sockaddr *, socklen_t *); extern int pth_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +extern int pth_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); extern int pth_poll(struct pollfd *, nfds_t, int); extern ssize_t pth_read(int, void *, size_t); extern ssize_t pth_write(int, const void *, size_t); @@ -527,6 +528,7 @@ #define sigprocmask pth_sigmask #define sigwait pth_sigwait #define select pth_select +#define pselect pth_pselect #define poll pth_poll #define connect pth_connect #define accept pth_accept Index: ossp-pkg/pth/pth.pod RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.pod,v rcsdiff -q -kk '-r1.156' '-r1.157' -u '/v/ossp/cvs/ossp-pkg/pth/pth.pod,v' 2>/dev/null --- pth.pod 2002/10/23 14:04:00 1.156 +++ pth.pod 2002/10/25 11:56:16 1.157 @@ -166,6 +166,7 @@ pth_accept, pth_connect, pth_select, +pth_pselect, pth_poll, pth_read, pth_readv, @@ -1681,6 +1682,15 @@ or have an exceptional condition pending, respectively. For more details about the arguments and return code semantics see select(2). +=item int B(int I, fd_set *I, fd_set *I, fd_set *I, const struct timespec *I, const sigset_t *I); + +This is a variant of the POSIX pselect(2) function, which in turn +is a stronger variant of 4.2BSD select(2). The difference is that +the higher-resolution C is passed instead of the +lower-resolution C and that a signal mask is specified +which is temporarily set while waiting for input. For more details about +the arguments and return code semantics see pselect(2) and select(2). + =item int B(struct pollfd *I, unsigned int I, int I); This is a variant of the SysV poll(2) function. It examines the I/O Index: ossp-pkg/pth/pth_high.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_high.c,v rcsdiff -q -kk '-r1.92' '-r1.93' -u '/v/ossp/cvs/ossp-pkg/pth/pth_high.c,v' 2>/dev/null --- pth_high.c 2002/10/25 11:53:28 1.92 +++ pth_high.c 2002/10/25 11:56:16 1.93 @@ -414,6 +414,38 @@ return rc; } +/* Pth variant of pth_pselect(2) */ +int pth_pselect(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, + const struct timespec *ts, const sigset_t *mask) +{ + sigset_t omask; + struct timeval tv; + struct timeval *tvp; + int rv; + + /* convert timeout */ + if (ts != NULL) { + tv.tv_sec = ts->tv_sec; + tv.tv_usec = ts->tv_nsec / 1000; + tvp = &tv; + } + else + tvp = NULL; + + /* optionally set signal mask */ + if (mask != NULL) + if (pth_sc(sigprocmask)(SIG_SETMASK, mask, &omask) < 0) + return pth_error(-1, errno); + + rv = pth_select(nfds, rfds, wfds, efds, tvp); + + /* optionally set signal mask */ + if (mask != NULL) + pth_shield { pth_sc(sigprocmask)(SIG_SETMASK, &omask, NULL); } + + return rv; +} + /* Pth variant of poll(2) */ int pth_poll(struct pollfd *pfd, nfds_t nfd, int timeout) { Index: ossp-pkg/pth/pth_syscall.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_syscall.c,v rcsdiff -q -kk '-r1.25' '-r1.26' -u '/v/ossp/cvs/ossp-pkg/pth/pth_syscall.c,v' 2>/dev/null --- pth_syscall.c 2002/10/20 16:22:03 1.25 +++ pth_syscall.c 2002/10/25 11:56:16 1.26 @@ -401,6 +401,18 @@ #endif } +/* ==== Pth hard syscall wrapper for pselect(2) ==== */ +int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); +int pselect(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, + const struct timespec *ts, const sigset_t *mask) +{ + /* external entry point for application */ + pth_implicit_init(); + return pth_pselect(nfds, rfds, wfds, efds, ts, mask); +} +/* NOTICE: internally fully emulated, so still no + internal exit point pth_sc_pselect necessary! */ + /* ==== Pth hard syscall wrapper for poll(2) ==== */ int poll(struct pollfd *pfd, nfds_t nfd, int timeout) {