OSSP CVS Repository

ossp - Check-in [2665]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2665
Date: 2002-Oct-25 13:56:16 (local)
2002-Oct-25 11:56:16 (UTC)
User:rse
Branch:
Comment: Add a Pth variant of the new POSIX pselect(2) function, including soft and hard syscall mapping support for it.
Tickets:
Inspections:
Files:
ossp-pkg/pth/ChangeLog      1.581 -> 1.582     4 inserted, 0 deleted
ossp-pkg/pth/pth.h.in      1.133 -> 1.134     2 inserted, 0 deleted
ossp-pkg/pth/pth.pod      1.156 -> 1.157     10 inserted, 0 deleted
ossp-pkg/pth/pth_high.c      1.92 -> 1.93     32 inserted, 0 deleted
ossp-pkg/pth/pth_syscall.c      1.25 -> 1.26     12 inserted, 0 deleted

ossp-pkg/pth/ChangeLog 1.581 -> 1.582

--- 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]


ossp-pkg/pth/pth.h.in 1.133 -> 1.134

--- 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


ossp-pkg/pth/pth.pod 1.156 -> 1.157

--- 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<pth_pselect>(int I<nfd>, fd_set *I<rfds>, fd_set *I<wfds>, fd_set *I<efds>, const struct timespec *I<timeout>, const sigset_t *I<sigmask>);
+
+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<struct timespec> is passed instead of the
+lower-resolution C<struct timeval> 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<pth_poll>(struct pollfd *I<fds>, unsigned int I<nfd>, int I<timeout>);
 
 This is a variant of the SysV poll(2) function. It examines the I/O


ossp-pkg/pth/pth_high.c 1.92 -> 1.93

--- 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)
 {


ossp-pkg/pth/pth_syscall.c 1.25 -> 1.26

--- 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)
 {

CVSTrac 2.0.1