OSSP CVS Repository

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

Check-in Number: 167
Date: 2000-Oct-02 11:26:47 (local)
2000-Oct-02 09:26:47 (UTC)
User:rse
Branch:
Comment: *** empty log message ***
Tickets:
Inspections:
Files:
ossp-pkg/pth/ChangeLog      1.531 -> 1.532     4 inserted, 0 deleted
ossp-pkg/pth/configure      1.142->removed
ossp-pkg/pth/configure.in      1.119->removed
ossp-pkg/pth/pth.h.in      added-> 1.127
ossp-pkg/pth/pth.pod      1.142 -> 1.143     15 inserted, 5 deleted
ossp-pkg/pth/pth_acdef.h.in      added-> 1.15
ossp-pkg/pth/pth_fork.c      added-> 1.11
ossp-pkg/pth/pth_high.c      1.74 -> 1.75     92 inserted, 27 deleted
ossp-pkg/pth/pth_p.h.in      1.26 -> 1.27     11 inserted, 0 deleted
ossp-pkg/pth/pth_syscall.c      added-> 1.20

ossp-pkg/pth/ChangeLog 1.531 -> 1.532

--- ChangeLog    2000/09/30 08:00:17     1.531
+++ ChangeLog    2000/10/03 09:26:47     1.532
@@ -21,6 +21,10 @@
     
   Changes between 1.4a3 and 1.4a4 (29-Jul-2000 to xx-Sep-2000)
 
+   *) Implemented a pth_system(3) function which is a thread-aware
+      clone of the POSIX system(2) function.
+      [Ralf S. Engelschall]
+
    *) Fixed typos in pth.pod: "fd" -> "s" for pth_connect/pth_accept.
       [Sebastian <scut@nb.in-berlin.de>]
 


ossp-pkg/pth/configure is a binary file


ossp-pkg/pth/configure.in 1.119 -> 1.120

--- configure.in 2000/08/18 09:31:15     1.119
+++ configure.in 2000/10/03 09:26:47     1.120
@@ -125,14 +125,14 @@
 AC_HEADER_STDC
 AC_HAVE_HEADERS(dnl
    stdio.h stdlib.h stdarg.h string.h signal.h unistd.h setjmp.h fcntl.h dnl
-   errno.h sys/types.h sys/time.h sys/wait.h sys/socket.h)
+   errno.h sys/types.h sys/time.h sys/wait.h sys/stat.h sys/socket.h)
 AC_CHECK_FUNCTIONS(dnl
    gettimeofday select sigaction sigprocmask sigpending sigsuspend)
 AC_BEGIN_DECISION([mandatory system headers and functions])
 AC_IFALLYES(dnl
    header:stdio.h header:stdlib.h header:stdarg.h header:string.h dnl
    header:signal.h header:unistd.h header:setjmp.h header:fcntl.h header:errno.h dnl
-   header:sys/types.h header:sys/time.h header:sys/wait.h header:sys/socket.h dnl
+   header:sys/types.h header:sys/time.h header:sys/wait.h header:sys/stat.h header:sys/socket.h dnl
    func:gettimeofday func:select func:sigaction func:sigprocmask dnl
    func:sigpending func:sigsuspend,
    AC_DECIDE(fine, [all fine]))
@@ -178,7 +178,7 @@
 AC_CHECK_FUNCTIONS(usleep strerror)
 
 dnl # check for various other headers which we might need
-AC_HAVE_HEADERS(sys/resource.h net/errno.h)
+AC_HAVE_HEADERS(sys/resource.h net/errno.h paths.h)
 
 dnl # at least the test programs need some socket stuff
 AC_CHECK_LIB(nsl, gethostname)


ossp-pkg/pth/pth.h.in -> 1.127

*** /dev/null    Sat Nov 23 01:11:00 2024
--- -    Sat Nov 23 01:11:12 2024
***************
*** 0 ****
--- 1,525 ----
+ /*
+ **  GNU Pth - The GNU Portable Threads
+ **  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ **
+ **  This file is part of GNU Pth, a non-preemptive thread scheduling
+ **  library which can be found at http://www.gnu.org/software/pth/.
+ **
+ **  This library is free software; you can redistribute it and/or
+ **  modify it under the terms of the GNU Lesser General Public
+ **  License as published by the Free Software Foundation; either
+ **  version 2.1 of the License, or (at your option) any later version.
+ **
+ **  This library is distributed in the hope that it will be useful,
+ **  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ **  Lesser General Public License for more details.
+ **
+ **  You should have received a copy of the GNU Lesser General Public
+ **  License along with this library; if not, write to the Free Software
+ **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ **  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
+ **
+ **  pth.h: Pth public API definitions
+ */
+                              /* ``What you see is all you get.''
+                                           -- Brian Kernighan      */
+ #ifndef _PTH_H_
+ #define _PTH_H_
+ 
+     /* the library version */
+ #ifndef PTH_VERSION_STR
+ #define PTH_VERSION_STR "@PTH_VERSION_STR@"
+ #endif
+ #ifndef PTH_VERSION_HEX
+ #define PTH_VERSION_HEX @PTH_VERSION_HEX@
+ #endif
+ #ifndef PTH_VERSION
+ #define PTH_VERSION PTH_VERSION_HEX
+ #endif
+ 
+     /* essential headers */
+ #include <sys/types.h>     /* for ssize_t, off_t */
+ #include <sys/time.h>      /* for struct timeval */
+ #include <sys/socket.h>    /* for sockaddr       */
+ #include <sys/signal.h>    /* for sigset_t       */
+ @EXTRA_INCLUDE_SYS_SELECT_H@
+ 
+     /* fallbacks for essential typedefs */
+ #ifndef _PTHREAD_PRIVATE
+ @FALLBACK_PID_T@
+ @FALLBACK_SIZE_T@
+ @FALLBACK_SSIZE_T@
+ @FALLBACK_SOCKLEN_T@
+ @FALLBACK_OFF_T@
+ @FALLBACK_SIG_ATOMIC_T@
+ @FALLBACK_NFDS_T@
+ #endif /* !_PTHREAD_PRIVATE */
+ 
+     /* extra structure definitions */
+ struct timeval;
+ 
+     /* essential values */
+ #ifndef FALSE
+ #define FALSE (0)
+ #endif
+ #ifndef TRUE
+ #define TRUE (!FALSE)
+ #endif
+ #ifndef NUL
+ #define NUL '\0'
+ #endif
+ #ifndef NULL
+ #define NULL (void *)0
+ #endif
+ 
+     /* bitmask generation */
+ #define _BIT(n) (1<<(n))
+ 
+     /* C++ support */
+ #ifdef __cplusplus
+ #define BEGIN_DECLARATION extern "C" {
+ #define END_DECLARATION   }
+ #else
+ #define BEGIN_DECLARATION /*nop*/
+ #define END_DECLARATION   /*nop*/
+ #endif
+ 
+ BEGIN_DECLARATION
+ 
+     /* some global constants */
+ #define PTH_KEY_MAX                  256
+ #define PTH_ATFORK_MAX               128
+ #define PTH_DESTRUCTOR_ITERATIONS    4
+ 
+     /* system call mapping support type (soft variant can be overridden) */
+ #define PTH_SYSCALL_HARD @PTH_SYSCALL_HARD@
+ #ifndef PTH_SYSCALL_SOFT
+ #define PTH_SYSCALL_SOFT @PTH_SYSCALL_SOFT@
+ #endif
+ 
+     /* queries for pth_ctrl() */
+ #define PTH_CTRL_GETAVLOAD            _BIT(1)
+ #define PTH_CTRL_GETPRIO              _BIT(2)
+ #define PTH_CTRL_GETNAME              _BIT(3)
+ #define PTH_CTRL_GETTHREADS_NEW       _BIT(4)
+ #define PTH_CTRL_GETTHREADS_READY     _BIT(5)
+ #define PTH_CTRL_GETTHREADS_RUNNING   _BIT(6)
+ #define PTH_CTRL_GETTHREADS_WAITING   _BIT(7)
+ #define PTH_CTRL_GETTHREADS_SUSPENDED _BIT(8)
+ #define PTH_CTRL_GETTHREADS_DEAD      _BIT(9)
+ #define PTH_CTRL_GETTHREADS           (PTH_CTRL_GETTHREADS_NEW|\
+                                        PTH_CTRL_GETTHREADS_READY|\
+                                        PTH_CTRL_GETTHREADS_RUNNING|\
+                                        PTH_CTRL_GETTHREADS_WAITING|\
+                                        PTH_CTRL_GETTHREADS_SUSPENDED|\
+                                        PTH_CTRL_GETTHREADS_DEAD)
+ #define PTH_CTRL_DUMPSTATE            _BIT(10)
+ 
+     /* the time value structure */
+ typedef struct timeval pth_time_t;
+ 
+     /* the unique thread id/handle */
+ typedef struct pth_st *pth_t;
+ struct pth_st;
+ 
+     /* thread states */
+ typedef enum pth_state_en {
+     PTH_STATE_SCHEDULER = 0,         /* the special scheduler thread only       */
+     PTH_STATE_NEW,                   /* spawned, but still not dispatched       */
+     PTH_STATE_READY,                 /* ready, waiting to be dispatched         */
+     PTH_STATE_WAITING,               /* suspended, waiting until event occurred */
+     PTH_STATE_DEAD                   /* terminated, waiting to be joined        */
+ } pth_state_t;
+ 
+     /* thread priority values */
+ #define PTH_PRIO_MAX                 +5
+ #define PTH_PRIO_STD                  0
+ #define PTH_PRIO_MIN                 -5
+ 
+     /* the thread attribute structure */
+ typedef struct pth_attr_st *pth_attr_t;
+ struct pth_attr_st;
+ 
+     /* attribute set/get commands for pth_attr_{get,set}() */
+ enum {
+     PTH_ATTR_PRIO,           /* RW [int]               priority of thread                */
+     PTH_ATTR_NAME,           /* RW [char *]            name of thread                    */
+     PTH_ATTR_JOINABLE,       /* RW [int]               thread detachment type            */
+     PTH_ATTR_CANCEL_STATE,   /* RW [unsigned int]      thread cancellation state         */
+     PTH_ATTR_STACK_SIZE,     /* RW [unsigned int]      stack size                        */
+     PTH_ATTR_STACK_ADDR,     /* RW [char *]            stack lower address               */
+     PTH_ATTR_TIME_SPAWN,     /* RO [pth_time_t]        time thread was spawned           */
+     PTH_ATTR_TIME_LAST,      /* RO [pth_time_t]        time thread was last dispatched   */
+     PTH_ATTR_TIME_RAN,       /* RO [pth_time_t]        time thread was running           */
+     PTH_ATTR_START_FUNC,     /* RO [void *(*)(void *)] thread start function             */
+     PTH_ATTR_START_ARG,      /* RO [void *]            thread start argument             */
+     PTH_ATTR_STATE,          /* RO [pth_state_t]       scheduling state                  */
+     PTH_ATTR_EVENTS,         /* RO [pth_event_t]       events the thread is waiting for  */
+     PTH_ATTR_BOUND           /* RO [int]               whether object is bound to thread */
+ };
+ 
+     /* default thread attribute */
+ #define PTH_ATTR_DEFAULT (pth_attr_t)(0)
+ 
+     /* the event structure */
+ typedef struct pth_event_st *pth_event_t;
+ struct pth_event_st;
+ 
+     /* event subject classes */
+ #define PTH_EVENT_FD                 _BIT(1)
+ #define PTH_EVENT_SELECT             _BIT(2)
+ #define PTH_EVENT_SIGS               _BIT(3)
+ #define PTH_EVENT_TIME               _BIT(4)
+ #define PTH_EVENT_MSG                _BIT(5)
+ #define PTH_EVENT_MUTEX              _BIT(6)
+ #define PTH_EVENT_COND               _BIT(7)
+ #define PTH_EVENT_TID                _BIT(8)
+ #define PTH_EVENT_FUNC               _BIT(9)
+ 
+     /* event occurange restrictions */
+ #define PTH_UNTIL_OCCURRED           _BIT(11)
+ #define PTH_UNTIL_FD_READABLE        _BIT(12)
+ #define PTH_UNTIL_FD_WRITEABLE       _BIT(13)
+ #define PTH_UNTIL_FD_EXCEPTION       _BIT(14)
+ #define PTH_UNTIL_TID_NEW            _BIT(15)
+ #define PTH_UNTIL_TID_READY          _BIT(16)
+ #define PTH_UNTIL_TID_WAITING        _BIT(17)
+ #define PTH_UNTIL_TID_DEAD           _BIT(18)
+ 
+     /* event structure handling modes */
+ #define PTH_MODE_REUSE               _BIT(20)
+ #define PTH_MODE_CHAIN               _BIT(21)
+ #define PTH_MODE_STATIC              _BIT(22)
+ 
+     /* event deallocation types */
+ enum { PTH_FREE_THIS, PTH_FREE_ALL };
+ 
+     /* event walking directions */
+ #define PTH_WALK_NEXT                _BIT(1)
+ #define PTH_WALK_PREV                _BIT(2)
+ 
+     /* the key type and init value */
+ typedef int pth_key_t;
+ #define PTH_KEY_INIT (-1)
+ 
+     /* the once structure and init value */
+ typedef int pth_once_t;
+ #define PTH_ONCE_INIT FALSE
+ 
+     /* general ring structure */
+ typedef struct pth_ringnode_st pth_ringnode_t;
+ struct pth_ringnode_st {
+     pth_ringnode_t *rn_next;
+     pth_ringnode_t *rn_prev;
+ };
+ typedef struct pth_ring_st pth_ring_t;
+ struct pth_ring_st {
+     pth_ringnode_t *r_hook;
+     unsigned int    r_nodes;
+ };
+ #define PTH_RING_INIT { NULL }
+ 
+     /* cancellation values */
+ #define PTH_CANCEL_ENABLE            _BIT(0)
+ #define PTH_CANCEL_DISABLE           _BIT(1)
+ #define PTH_CANCEL_ASYNCHRONOUS      _BIT(2)
+ #define PTH_CANCEL_DEFERRED          _BIT(3)
+ #define PTH_CANCEL_DEFAULT           (PTH_CANCEL_ENABLE|PTH_CANCEL_DEFERRED)
+ #define PTH_CANCELED                 ((void *)-1)
+ 
+    /* mutex values */
+ #define PTH_MUTEX_INITIALIZED        _BIT(0)
+ #define PTH_MUTEX_LOCKED             _BIT(1)
+ #define PTH_MUTEX_INIT               { {NULL, NULL}, PTH_MUTEX_INITIALIZED, NULL, 0 }
+ 
+    /* read-write lock values */
+ enum { PTH_RWLOCK_RD, PTH_RWLOCK_RW };
+ #define PTH_RWLOCK_INITIALIZED       _BIT(0)
+ #define PTH_RWLOCK_INIT              { PTH_RWLOCK_INITIALIZED, PTH_RWLOCK_RD, 0, \
+                                        PTH_MUTEX_INIT, PTH_MUTEX_INIT }
+ 
+    /* condition variable values */
+ #define PTH_COND_INITIALIZED         _BIT(0)
+ #define PTH_COND_SIGNALED            _BIT(1)
+ #define PTH_COND_BROADCAST           _BIT(2)
+ #define PTH_COND_HANDLED             _BIT(3)
+ #define PTH_COND_INIT                { PTH_COND_INITIALIZED }
+ 
+    /* barrier variable values */
+ #define PTH_BARRIER_INITIALIZED      _BIT(0)
+ #define PTH_BARRIER_INIT(threshold)  { PTH_BARRIER_INITIALIZED, (threshold), 0, 0, \
+                                        PTH_MUTEX_INIT, PTH_COND_INIT }
+ #define PTH_BARRIER_HEADLIGHT        (-1)
+ #define PTH_BARRIER_TAILLIGHT        (-2)
+ 
+     /* the message port structure */
+ typedef struct pth_msgport_st *pth_msgport_t;
+ struct pth_msgport_st;
+ 
+     /* the message structure */
+ typedef struct pth_message_st pth_message_t;
+ struct pth_message_st { /* not hidden to allow inclusion */
+     pth_ringnode_t m_node;
+     pth_msgport_t  m_replyport;
+     unsigned int   m_size;
+     void          *m_data;
+ };
+ 
+     /* the mutex structure */
+ typedef struct pth_mutex_st pth_mutex_t;
+ struct pth_mutex_st { /* not hidden to avoid destructor */
+     pth_ringnode_t mx_node;
+     int            mx_state;
+     pth_t          mx_owner;
+     unsigned long  mx_count;
+ };
+ 
+     /* the read-write lock structure */
+ typedef struct pth_rwlock_st pth_rwlock_t;
+ struct pth_rwlock_st { /* not hidden to avoid destructor */
+     int            rw_state;
+     unsigned int   rw_mode;
+     unsigned long  rw_readers;
+     pth_mutex_t    rw_mutex_rd;
+     pth_mutex_t    rw_mutex_rw;
+ };
+ 
+     /* the condition variable structure */
+ typedef struct pth_cond_st pth_cond_t;
+ struct pth_cond_st { /* not hidden to avoid destructor */
+     unsigned long cn_state;
+     unsigned int  cn_waiters;
+ };
+ 
+     /* the barrier variable structure */
+ typedef struct pth_barrier_st pth_barrier_t;
+ struct pth_barrier_st { /* not hidden to avoid destructor */
+     unsigned long br_state;
+     int           br_threshold;
+     int           br_count;
+     int           br_cycle;
+     pth_cond_t    br_cond;
+     pth_mutex_t   br_mutex;
+ };
+ 
+     /* filedescriptor blocking modes */
+ enum {
+     PTH_FDMODE_ERROR = -1,
+     PTH_FDMODE_POLL  =  0,
+     PTH_FDMODE_BLOCK,
+     PTH_FDMODE_NONBLOCK
+ };
+ 
+     /* optionally fake poll(2) data structure and options */
+ #ifndef _PTHREAD_PRIVATE
+ #define PTH_FAKE_POLL @PTH_FAKE_POLL@
+ #if !(PTH_FAKE_POLL)
+ /* use vendor poll(2) environment */
+ #include <poll.h>
+ #ifndef INFTIM
+ #define INFTIM (-1)
+ #endif
+ #else
+ /* fake a poll(2) environment */
+ #define POLLIN      0x0001      /* any readable data available   */
+ #define POLLPRI     0x0002      /* OOB/Urgent readable data      */
+ #define POLLOUT     0x0004      /* file descriptor is writeable  */
+ #define POLLERR     0x0008      /* some poll error occurred      */
+ #define POLLHUP     0x0010      /* file descriptor was "hung up" */
+ #define POLLNVAL    0x0020      /* requested events "invalid"    */
+ #define POLLRDNORM  POLLIN
+ #define POLLRDBAND  POLLIN
+ #define POLLWRNORM  POLLOUT
+ #define POLLWRBAND  POLLOUT
+ #ifndef INFTIM
+ #define INFTIM      (-1)        /* poll infinite */
+ #endif
+ struct pollfd {
+     int fd;                     /* which file descriptor to poll */
+     short events;               /* events we are interested in   */
+     short revents;              /* events found on return        */
+ };
+ #endif
+ #endif /* !_PTHREAD_PRIVATE */
+ 
+     /* optionally fake readv(2)/writev(2) data structure and options */
+ #ifndef _PTHREAD_PRIVATE
+ #define PTH_FAKE_RWV @PTH_FAKE_RWV@
+ #if !(PTH_FAKE_RWV)
+ /* use vendor readv(2)/writev(2) environment */
+ #include <sys/uio.h>
+ #ifndef UIO_MAXIOV
+ #define UIO_MAXIOV 1024
+ #endif
+ #else
+ /* fake a readv(2)/writev(2) environment */
+ struct iovec {
+     void  *iov_base;  /* memory base address */
+     size_t iov_len;   /* memory chunk length */
+ };
+ #ifndef UIO_MAXIOV
+ #define UIO_MAXIOV 1024
+ #endif
+ #endif
+ #endif /* !_PTHREAD_PRIVATE */
+ 
+     /* extension support */
+ #define PTH_EXT_SFIO @PTH_EXT_SFIO@
+ 
+     /* Sfio extension support */
+ #if @PTH_EXT_SFIO@
+ #include <sfio.h>
+ #else
+ typedef void *Sfdisc_t;
+ #endif
+ 
+     /* global functions */
+ extern int            pth_init(void);
+ extern int            pth_kill(void);
+ extern long           pth_ctrl(unsigned long, ...);
+ extern long           pth_version(void);
+ 
+     /* thread attribute functions */
+ extern pth_attr_t     pth_attr_of(pth_t);
+ extern pth_attr_t     pth_attr_new(void);
+ extern int            pth_attr_init(pth_attr_t);
+ extern int            pth_attr_set(pth_attr_t, int, ...);
+ extern int            pth_attr_get(pth_attr_t, int, ...);
+ extern int            pth_attr_destroy(pth_attr_t);
+ 
+     /* thread functions */
+ extern pth_t          pth_spawn(pth_attr_t, void *(*)(void *), void *);
+ extern int            pth_once(pth_once_t *, void (*)(void *), void *);
+ extern pth_t          pth_self(void);
+ extern int            pth_suspend(pth_t);
+ extern int            pth_resume(pth_t);
+ extern int            pth_yield(pth_t);
+ extern int            pth_nap(pth_time_t);
+ extern int            pth_wait(pth_event_t);
+ extern int            pth_cancel(pth_t);
+ extern int            pth_abort(pth_t);
+ extern int            pth_raise(pth_t, int);
+ extern int            pth_join(pth_t, void **);
+ extern void           pth_exit(void *);
+ 
+     /* utility functions */
+ extern int            pth_fdmode(int, int);
+ extern pth_time_t     pth_time(long, long);
+ extern pth_time_t     pth_timeout(long, long);
+ 
+     /* cancellation functions */
+ extern void           pth_cancel_state(int, int *);
+ extern void           pth_cancel_point(void);
+ 
+     /* event functions */
+ extern pth_event_t    pth_event(unsigned long, ...);
+ extern unsigned long  pth_event_typeof(pth_event_t);
+ extern int            pth_event_extract(pth_event_t ev, ...);
+ extern pth_event_t    pth_event_concat(pth_event_t, ...);
+ extern pth_event_t    pth_event_isolate(pth_event_t);
+ extern pth_event_t    pth_event_walk(pth_event_t, unsigned int);
+ extern int            pth_event_occurred(pth_event_t);
+ extern int            pth_event_free(pth_event_t, int);
+ 
+     /* key-based storage functions */
+ extern int            pth_key_create(pth_key_t *, void (*)(void *));
+ extern int            pth_key_delete(pth_key_t);
+ extern int            pth_key_setdata(pth_key_t, const void *);
+ extern void          *pth_key_getdata(pth_key_t);
+ 
+     /* message port functions */
+ extern pth_msgport_t  pth_msgport_create(const char *);
+ extern void           pth_msgport_destroy(pth_msgport_t);
+ extern pth_msgport_t  pth_msgport_find(const char *);
+ extern int            pth_msgport_pending(pth_msgport_t);
+ extern int            pth_msgport_put(pth_msgport_t, pth_message_t *);
+ extern pth_message_t *pth_msgport_get(pth_msgport_t);
+ extern int            pth_msgport_reply(pth_message_t *);
+ 
+     /* cleanup handler functions */
+ extern int            pth_cleanup_push(void (*)(void *), void *);
+ extern int            pth_cleanup_pop(int);
+ 
+     /* process forking functions */
+ extern int            pth_atfork_push(void (*)(void *), void (*)(void *), void (*)(void *), void *);
+ extern int            pth_atfork_pop(void);
+ extern pid_t          pth_fork(void);
+ 
+     /* synchronization functions */
+ extern int            pth_mutex_init(pth_mutex_t *);
+ extern int            pth_mutex_acquire(pth_mutex_t *, int, pth_event_t);
+ extern int            pth_mutex_release(pth_mutex_t *);
+ extern int            pth_rwlock_init(pth_rwlock_t *);
+ extern int            pth_rwlock_acquire(pth_rwlock_t *, int, int, pth_event_t);
+ extern int            pth_rwlock_release(pth_rwlock_t *);
+ extern int            pth_cond_init(pth_cond_t *);
+ extern int            pth_cond_await(pth_cond_t *, pth_mutex_t *, pth_event_t);
+ extern int            pth_cond_notify(pth_cond_t *, int);
+ extern int            pth_barrier_init(pth_barrier_t *, int);
+ extern int            pth_barrier_reach(pth_barrier_t *);
+ 
+     /* extension functions */
+ extern Sfdisc_t      *pth_sfiodisc(void);
+ 
+     /* generalized variants of replacement functions */
+ extern int            pth_sigwait_ev(const sigset_t *, int *, pth_event_t);
+ extern int            pth_connect_ev(int, const struct sockaddr *, socklen_t, pth_event_t);
+ extern int            pth_accept_ev(int, struct sockaddr *, socklen_t *, pth_event_t);
+ extern int            pth_select_ev(int, fd_set *, fd_set *, fd_set *, struct timeval *, pth_event_t);
+ extern int            pth_poll_ev(struct pollfd *, nfds_t, int, pth_event_t);
+ extern ssize_t        pth_read_ev(int, void *, size_t, pth_event_t);
+ extern ssize_t        pth_write_ev(int, const void *, size_t, pth_event_t);
+ extern ssize_t        pth_readv_ev(int, const struct iovec *, int, pth_event_t);
+ extern ssize_t        pth_writev_ev(int, const struct iovec *, int, pth_event_t);
+ extern ssize_t        pth_recv_ev(int, void *, size_t, int, pth_event_t);
+ extern ssize_t        pth_send_ev(int, const void *, size_t, int, pth_event_t);
+ extern ssize_t        pth_recvfrom_ev(int, void *, size_t, int, struct sockaddr *, socklen_t *, pth_event_t);
+ extern ssize_t        pth_sendto_ev(int, const void *, size_t, int, const struct sockaddr *, socklen_t, pth_event_t);
+ 
+     /* standard replacement functions */
+ extern int            pth_usleep(unsigned int);
+ extern unsigned int   pth_sleep(unsigned int);
+ extern pid_t          pth_waitpid(pid_t, int *, int);
+ extern int            pth_system(const char *);
+ extern int            pth_sigmask(int, const sigset_t *, sigset_t *);
+ extern int            pth_sigwait(const sigset_t *, int *);
+ 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_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);
+ extern ssize_t        pth_readv(int, const struct iovec *, int);
+ extern ssize_t        pth_writev(int, const struct iovec *, int);
+ extern ssize_t        pth_recv(int, void *, size_t, int);
+ extern ssize_t        pth_send(int, const void *, size_t, int);
+ extern ssize_t        pth_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
+ extern ssize_t        pth_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+ extern ssize_t        pth_pread(int, void *, size_t, off_t);
+ extern ssize_t        pth_pwrite(int, const void *, size_t, off_t);
+ 
+ END_DECLARATION
+ 
+     /* soft system call mapping support */
+ #if PTH_SYSCALL_SOFT && !defined(_PTH_PRIVATE)
+ #define fork          pth_fork
+ #define waitpid       pth_waitpid
+ #define system        pth_system
+ #define sleep         pth_sleep
+ #define sigprocmask   pth_sigmask
+ #define sigwait       pth_sigwait
+ #define select        pth_select
+ #define poll          pth_poll
+ #define connect       pth_connect
+ #define accept        pth_accept
+ #define read          pth_read
+ #define write         pth_write
+ #define readv         pth_readv
+ #define writev        pth_writev
+ #define pread         pth_pread
+ #define pwrite        pth_pwrite
+ #endif
+ 
+ #endif /* _PTH_H_ */
+ 


ossp-pkg/pth/pth.pod 1.142 -> 1.143

--- pth.pod      2000/09/30 08:00:18     1.142
+++ pth.pod      2000/10/03 09:26:47     1.143
@@ -159,6 +159,7 @@
 pth_usleep,
 pth_sleep,
 pth_waitpid,
+pth_system,
 pth_sigmask,
 pth_sigwait,
 pth_accept,
@@ -1608,6 +1609,15 @@
 current thread and not the whole process.  For more details about the
 arguments and return code semantics see waitpid(2).
 
+=item int B<pth_system>(const char *I<cmd>);
+
+This is a variant of the POSIX system(3) function. It executes the
+shell command I<cmd> with Bourne Shell (C<sh>) and suspends the current
+threads execution until this command terminates. The difference between
+system(3) and pth_system(3) is that that pth_system(3) suspends only
+the execution of the current thread and not the whole process. For more
+details about the arguments and return code semantics see system(3).
+
 =item int B<pth_sigmask>(int I<how>, const sigset_t *I<set>, sigset_t *I<oset>)
 
 This is the B<Pth> thread-related equivalent of POSIX sigprocmask(2) respectively
@@ -2128,8 +2138,8 @@
 building B<Pth> with C<--enable-syscall-soft>. This then triggers some
 C<#define>'s in the C<pth.h> header which map for instance read(3) to
 pth_read(3), etc.  Currently the following functions are mapped: fork(2),
-sleep(3), sigwait(3), waitpid(2), select(2), poll(2), connect(2),
-accept(2), read(2), write(2).
+sleep(3), sigwait(3), waitpid(2), system(3), select(2), poll(2),
+connect(2), accept(2), read(2), write(2).
 
 The drawback of this approach is just that really all source files
 of the application where these function calls occur have to include
@@ -2143,9 +2153,9 @@
 function exists and there it can be enabled by building B<Pth> with
 C<--enable-syscall-hard>. This then builds wrapper functions (for instances
 read(3)) into the B<Pth> library which internally call the real B<Pth>
-replacement functions (pth_read(3)).  Currently the following functions are
-mapped: fork(2), sleep(3), waitpid(2), select(2), poll(2), connect(2),
-accept(2), read(2), write(2).
+replacement functions (pth_read(3)). Currently the following functions
+are mapped: fork(2), sleep(3), waitpid(2), system(3), select(2),
+poll(2), connect(2), accept(2), read(2), write(2).
 
 The drawback of this approach is that it depends on syscall(2) interface
 and prototype conflicts can occur while building the wrapper functions


ossp-pkg/pth/pth_acdef.h.in -> 1.15

*** /dev/null    Sat Nov 23 01:11:00 2024
--- -    Sat Nov 23 01:11:12 2024
***************
*** 0 ****
--- 1,219 ----
+ /* pth_acdef.h.in.  Generated automatically from - by autoheader.  */
+ /*
+ **  GNU Pth - The GNU Portable Threads
+ **  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ **
+ **  This file is part of GNU Pth, a non-preemptive thread scheduling
+ **  library which can be found at http://www.gnu.org/software/pth/.
+ **
+ **  This library is free software; you can redistribute it and/or
+ **  modify it under the terms of the GNU Lesser General Public
+ **  License as published by the Free Software Foundation; either
+ **  version 2.1 of the License, or (at your option) any later version.
+ **
+ **  This library is distributed in the hope that it will be useful,
+ **  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ **  Lesser General Public License for more details.
+ **
+ **  You should have received a copy of the GNU Lesser General Public
+ **  License along with this library; if not, write to the Free Software
+ **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ **  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
+ **
+ **  pth_acdef.h Autoconf defines
+ */
+ 
+ #ifndef _PTH_ACDEF_H_
+ #define _PTH_ACDEF_H_
+ 
+ 
+ /* Define if you have the ANSI C header files.  */
+ #undef STDC_HEADERS
+ 
+ /* the custom Autoconf defines */
+ #undef HAVE_SIG_ATOMIC_T
+ #undef HAVE_PID_T
+ #undef HAVE_STACK_T
+ #undef HAVE_SIZE_T
+ #undef HAVE_SSIZE_T
+ #undef HAVE_SOCKLEN_T
+ #undef HAVE_NFDS_T
+ #undef HAVE_OFF_T
+ #undef HAVE_GETTIMEOFDAY_ARGS1
+ #undef HAVE_STRUCT_TIMESPEC
+ #undef HAVE_SYS_READ
+ #undef HAVE_POLLIN
+ #undef HAVE_SS_SP
+ #undef HAVE_SS_BASE
+ #undef HAVE_LONGLONG
+ #undef HAVE_LONGDOUBLE
+ #undef PTH_DEBUG
+ #undef PTH_NSIG
+ #undef PTH_MCTX_MTH_use
+ #undef PTH_MCTX_DSP_use
+ #undef PTH_MCTX_STK_use
+ #undef PTH_STACKGROWTH
+ #undef PTH_DMALLOC
+ 
+ /* Define if you have the _longjmp function.  */
+ #undef HAVE__LONGJMP
+ 
+ /* Define if you have the _setjmp function.  */
+ #undef HAVE__SETJMP
+ 
+ /* Define if you have the getcontext function.  */
+ #undef HAVE_GETCONTEXT
+ 
+ /* Define if you have the gettimeofday function.  */
+ #undef HAVE_GETTIMEOFDAY
+ 
+ /* Define if you have the longjmp function.  */
+ #undef HAVE_LONGJMP
+ 
+ /* Define if you have the makecontext function.  */
+ #undef HAVE_MAKECONTEXT
+ 
+ /* Define if you have the poll function.  */
+ #undef HAVE_POLL
+ 
+ /* Define if you have the readv function.  */
+ #undef HAVE_READV
+ 
+ /* Define if you have the select function.  */
+ #undef HAVE_SELECT
+ 
+ /* Define if you have the setcontext function.  */
+ #undef HAVE_SETCONTEXT
+ 
+ /* Define if you have the setjmp function.  */
+ #undef HAVE_SETJMP
+ 
+ /* Define if you have the sigaction function.  */
+ #undef HAVE_SIGACTION
+ 
+ /* Define if you have the sigaltstack function.  */
+ #undef HAVE_SIGALTSTACK
+ 
+ /* Define if you have the siglongjmp function.  */
+ #undef HAVE_SIGLONGJMP
+ 
+ /* Define if you have the sigpending function.  */
+ #undef HAVE_SIGPENDING
+ 
+ /* Define if you have the sigprocmask function.  */
+ #undef HAVE_SIGPROCMASK
+ 
+ /* Define if you have the sigsetjmp function.  */
+ #undef HAVE_SIGSETJMP
+ 
+ /* Define if you have the sigstack function.  */
+ #undef HAVE_SIGSTACK
+ 
+ /* Define if you have the sigsuspend function.  */
+ #undef HAVE_SIGSUSPEND
+ 
+ /* Define if you have the strerror function.  */
+ #undef HAVE_STRERROR
+ 
+ /* Define if you have the swapcontext function.  */
+ #undef HAVE_SWAPCONTEXT
+ 
+ /* Define if you have the syscall function.  */
+ #undef HAVE_SYSCALL
+ 
+ /* Define if you have the usleep function.  */
+ #undef HAVE_USLEEP
+ 
+ /* Define if you have the writev function.  */
+ #undef HAVE_WRITEV
+ 
+ /* Define if you have the <dmalloc.h> header file.  */
+ #undef HAVE_DMALLOC_H
+ 
+ /* Define if you have the <errno.h> header file.  */
+ #undef HAVE_ERRNO_H
+ 
+ /* Define if you have the <fcntl.h> header file.  */
+ #undef HAVE_FCNTL_H
+ 
+ /* Define if you have the <net/errno.h> header file.  */
+ #undef HAVE_NET_ERRNO_H
+ 
+ /* Define if you have the <paths.h> header file.  */
+ #undef HAVE_PATHS_H
+ 
+ /* Define if you have the <pthread.h> header file.  */
+ #undef HAVE_PTHREAD_H
+ 
+ /* Define if you have the <setjmp.h> header file.  */
+ #undef HAVE_SETJMP_H
+ 
+ /* Define if you have the <sfio.h> header file.  */
+ #undef HAVE_SFIO_H
+ 
+ /* Define if you have the <signal.h> header file.  */
+ #undef HAVE_SIGNAL_H
+ 
+ /* Define if you have the <stdarg.h> header file.  */
+ #undef HAVE_STDARG_H
+ 
+ /* Define if you have the <stdio.h> header file.  */
+ #undef HAVE_STDIO_H
+ 
+ /* Define if you have the <stdlib.h> header file.  */
+ #undef HAVE_STDLIB_H
+ 
+ /* Define if you have the <string.h> header file.  */
+ #undef HAVE_STRING_H
+ 
+ /* Define if you have the <sys/resource.h> header file.  */
+ #undef HAVE_SYS_RESOURCE_H
+ 
+ /* Define if you have the <sys/select.h> header file.  */
+ #undef HAVE_SYS_SELECT_H
+ 
+ /* Define if you have the <sys/socket.h> header file.  */
+ #undef HAVE_SYS_SOCKET_H
+ 
+ /* Define if you have the <sys/socketcall.h> header file.  */
+ #undef HAVE_SYS_SOCKETCALL_H
+ 
+ /* Define if you have the <sys/stat.h> header file.  */
+ #undef HAVE_SYS_STAT_H
+ 
+ /* Define if you have the <sys/syscall.h> header file.  */
+ #undef HAVE_SYS_SYSCALL_H
+ 
+ /* Define if you have the <sys/time.h> header file.  */
+ #undef HAVE_SYS_TIME_H
+ 
+ /* Define if you have the <sys/types.h> header file.  */
+ #undef HAVE_SYS_TYPES_H
+ 
+ /* Define if you have the <sys/uio.h> header file.  */
+ #undef HAVE_SYS_UIO_H
+ 
+ /* Define if you have the <sys/wait.h> header file.  */
+ #undef HAVE_SYS_WAIT_H
+ 
+ /* Define if you have the <ucontext.h> header file.  */
+ #undef HAVE_UCONTEXT_H
+ 
+ /* Define if you have the <unistd.h> header file.  */
+ #undef HAVE_UNISTD_H
+ 
+ /* Define if you have the dmalloc library (-ldmalloc).  */
+ #undef HAVE_LIBDMALLOC
+ 
+ /* Define if you have the nsl library (-lnsl).  */
+ #undef HAVE_LIBNSL
+ 
+ /* Define if you have the sfio library (-lsfio).  */
+ #undef HAVE_LIBSFIO
+ 
+ /* Define if you have the socket library (-lsocket).  */
+ #undef HAVE_LIBSOCKET
+ 
+ #endif /* _PTH_ACDEF_H_ */
+ 


ossp-pkg/pth/pth_fork.c -> 1.11

*** /dev/null    Sat Nov 23 01:11:00 2024
--- -    Sat Nov 23 01:11:12 2024
***************
*** 0 ****
--- 1,99 ----
+ /*
+ **  GNU Pth - The GNU Portable Threads
+ **  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ **
+ **  This file is part of GNU Pth, a non-preemptive thread scheduling
+ **  library which can be found at http://www.gnu.org/software/pth/.
+ **
+ **  This library is free software; you can redistribute it and/or
+ **  modify it under the terms of the GNU Lesser General Public
+ **  License as published by the Free Software Foundation; either
+ **  version 2.1 of the License, or (at your option) any later version.
+ **
+ **  This library is distributed in the hope that it will be useful,
+ **  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ **  Lesser General Public License for more details.
+ **
+ **  You should have received a copy of the GNU Lesser General Public
+ **  License along with this library; if not, write to the Free Software
+ **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ **  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
+ **
+ **  pth_fork.c: Pth process forking support
+ */
+                              /* ``Every day of my life
+                                   I am forced to add another
+                                   name to the list of people
+                                   who piss me off!''
+                                             -- Calvin          */
+ #include "pth_p.h"
+ 
+ struct pth_atfork_st {
+     void (*prepare)(void *);
+     void (*parent)(void *);
+     void (*child)(void *);
+     void *arg;
+ };
+ 
+ static struct pth_atfork_st pth_atfork_list[PTH_ATFORK_MAX];
+ static int pth_atfork_idx = 0;
+ 
+ int pth_atfork_push(void (*prepare)(void *), void (*parent)(void *),
+                     void (*child)(void *), void *arg)
+ {
+     if (pth_atfork_idx > PTH_ATFORK_MAX-1)
+         return_errno(FALSE, ENOMEM);
+     pth_atfork_list[pth_atfork_idx].prepare = prepare;
+     pth_atfork_list[pth_atfork_idx].parent  = parent;
+     pth_atfork_list[pth_atfork_idx].child   = child;
+     pth_atfork_list[pth_atfork_idx].arg     = arg;
+     pth_atfork_idx++;
+     return TRUE;
+ }
+ 
+ int pth_atfork_pop(void)
+ {
+     if (pth_atfork_idx <= 0)
+         return FALSE;
+     pth_atfork_idx--;
+     return TRUE;
+ }
+ 
+ pid_t pth_fork(void)
+ {
+     pid_t pid;
+     int i;
+ 
+     /* run preparation handlers in LIFO order */
+     for (i = pth_atfork_idx-1; i >= 0; i--)
+         if (pth_atfork_list[i].prepare != NULL)
+             pth_atfork_list[i].prepare(pth_atfork_list[i].arg);
+ 
+     /* fork the process */
+     if ((pid = pth_sc(fork)()) == -1)
+         return FALSE;
+ 
+     /* handle parent and child contexts */
+     if (pid != 0) {
+         /* Parent: */
+ 
+         /* run parent handlers in FIFO order */
+         for (i = 0; i <= pth_atfork_idx-1; i++)
+             if (pth_atfork_list[i].parent != NULL)
+                 pth_atfork_list[i].parent(pth_atfork_list[i].arg);
+     }
+     else {
+         /* Child: */
+ 
+         /* kick out all threads except for the current one and the scheduler */
+         pth_scheduler_drop();
+ 
+         /* run child handlers in FIFO order */
+         for (i = 0; i <= pth_atfork_idx-1; i++)
+             if (pth_atfork_list[i].child != NULL)
+                 pth_atfork_list[i].child(pth_atfork_list[i].arg);
+     }
+     return pid;
+ }
+ 


ossp-pkg/pth/pth_high.c 1.74 -> 1.75

--- pth_high.c   2000/08/18 08:35:29     1.74
+++ pth_high.c   2000/10/03 09:26:47     1.75
@@ -141,6 +141,98 @@
     return 0;
 }
 
+/* Pth variant of waitpid(2) */
+pid_t pth_waitpid(pid_t wpid, int *status, int options)
+{
+    pth_event_t ev;
+    static pth_key_t ev_key = PTH_KEY_INIT;
+    pid_t pid;
+
+    pth_debug2("pth_waitpid: called from thread \"%s\"", pth_current->name);
+
+    for (;;) {
+        /* do a non-blocking poll for the pid */
+        while (   (pid = pth_sc(waitpid)(wpid, status, options|WNOHANG)) < 0 
+               && errno == EINTR) ;
+
+        /* if pid was found or caller requested a polling return immediately */
+        if (pid == -1 || pid > 0 || (pid == 0 && (options & WNOHANG)))
+            break;
+
+        /* else wait a little bit */
+        ev = pth_event(PTH_EVENT_TIME|PTH_MODE_STATIC, &ev_key, pth_timeout(0,250000));
+        pth_wait(ev);
+    }
+
+    pth_debug2("pth_waitpid: leave to thread \"%s\"", pth_current->name);
+    return pid;
+}
+
+/* Pth variant of system(3) */
+int pth_system(const char *cmd)
+{
+    struct sigaction sa_ign, sa_int, sa_quit;
+    sigset_t ss_block, ss_old;
+    struct stat sb;
+    pid_t pid;
+    int pstat;
+
+    /* POSIX calling convention: determine whether the
+       Bourne Shell ("sh") is available on this platform */
+    if (cmd == NULL) {
+        if (stat(PTH_PATH_BINSH, &sb) == -1)
+            return 0;
+        return 1;
+    }
+
+    /* temporarily ignore SIGINT and SIGQUIT actions */
+    sa_ign.sa_handler = SIG_IGN;
+    sigemptyset(&sa_ign.sa_mask);
+    sa_ign.sa_flags = 0;
+    sigaction(SIGINT,  &sa_ign, &sa_int);
+    sigaction(SIGQUIT, &sa_ign, &sa_quit);
+
+    /* block SIGCHLD signal */
+    sigemptyset(&ss_block);
+    sigaddset(&ss_block, SIGCHLD);
+    sigprocmask(SIG_BLOCK, &ss_block, &ss_old);
+
+    /* fork the current process */
+    pstat = -1;
+    switch (pid = pth_fork()) {
+        case -1: /* error */
+            break;
+
+        case 0:  /* child */
+            /* restore original signal dispositions and execute the command */
+            sigaction(SIGINT,  &sa_int,  NULL);
+            sigaction(SIGQUIT, &sa_quit, NULL);
+            sigprocmask(SIG_SETMASK, &ss_old, NULL);
+
+            /* stop the Pth scheduling */
+            pth_scheduler_kill();
+
+            /* execute the command through Bourne Shell */
+            execl(PTH_PATH_BINSH, "sh", "-c", cmd, NULL);
+
+            /* POSIX compliant return in case execution failed */
+            exit(127);
+
+        default: /* parent */
+            /* wait until child process terminates */
+            pid = pth_waitpid(pid, &pstat, 0);
+            break;
+    }
+
+    /* restore original signal dispositions and execute the command */
+    sigaction(SIGINT,  &sa_int,  NULL);
+    sigaction(SIGQUIT, &sa_quit, NULL);
+    sigprocmask(SIG_SETMASK, &ss_old, NULL);
+
+    /* return error or child process result code */
+    return (pid == -1 ? -1 : pstat);
+}
+
 /* Pth variant of select(2) */
 int pth_select(int nfds, fd_set *readfds, fd_set *writefds,
                fd_set *exceptfds, struct timeval *timeout)
@@ -637,33 +729,6 @@
     return rv;
 }
 
-/* Pth variant of waitpid(2) */
-pid_t pth_waitpid(pid_t wpid, int *status, int options)
-{
-    pth_event_t ev;
-    static pth_key_t ev_key = PTH_KEY_INIT;
-    pid_t pid;
-
-    pth_debug2("pth_waitpid: called from thread \"%s\"", pth_current->name);
-
-    for (;;) {
-        /* do a non-blocking poll for the pid */
-        while (   (pid = pth_sc(waitpid)(wpid, status, options|WNOHANG)) < 0 
-               && errno == EINTR) ;
-
-        /* if pid was found or caller requested a polling return immediately */
-        if (pid == -1 || pid > 0 || (pid == 0 && (options & WNOHANG)))
-            break;
-
-        /* else wait a little bit */
-        ev = pth_event(PTH_EVENT_TIME|PTH_MODE_STATIC, &ev_key, pth_timeout(0,250000));
-        pth_wait(ev);
-    }
-
-    pth_debug2("pth_waitpid: leave to thread \"%s\"", pth_current->name);
-    return pid;
-}
-
 /* Pth variant of readv(2) */
 ssize_t pth_readv(int fd, const struct iovec *iov, int iovcnt)
 {


ossp-pkg/pth/pth_p.h.in 1.26 -> 1.27

--- pth_p.h.in   2000/07/01 12:40:51     1.26
+++ pth_p.h.in   2000/10/03 09:26:47     1.27
@@ -40,6 +40,7 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/wait.h>
+#include <sys/stat.h>
 #include <sys/socket.h>
 
 /* library version */
@@ -69,6 +70,16 @@
 #include <dmalloc.h>
 #endif
 
+/* paths */
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#ifdef _PATH_BSHELL
+#define PTH_PATH_BINSH _PATH_BSHELL
+#else
+#define PTH_PATH_BINSH "/bin/sh"
+#endif
+
 /* non-blocking flags */
 #ifdef  O_NONBLOCK
 #define O_NONBLOCKING O_NONBLOCK


ossp-pkg/pth/pth_syscall.c -> 1.20

*** /dev/null    Sat Nov 23 01:11:00 2024
--- -    Sat Nov 23 01:11:12 2024
***************
*** 0 ****
--- 1,337 ----
+ /*
+ **  GNU Pth - The GNU Portable Threads
+ **  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ **
+ **  This file is part of GNU Pth, a non-preemptive thread scheduling
+ **  library which can be found at http://www.gnu.org/software/pth/.
+ **
+ **  This library is free software; you can redistribute it and/or
+ **  modify it under the terms of the GNU Lesser General Public
+ **  License as published by the Free Software Foundation; either
+ **  version 2.1 of the License, or (at your option) any later version.
+ **
+ **  This library is distributed in the hope that it will be useful,
+ **  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ **  Lesser General Public License for more details.
+ **
+ **  You should have received a copy of the GNU Lesser General Public
+ **  License along with this library; if not, write to the Free Software
+ **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ **  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
+ **
+ **  pth_syscall.c: Pth direct syscall support
+ */
+                              /* ``Free Software: generous programmers
+                                   from around the world all join
+                                   forces to help you shoot yourself
+                                   in the foot for free.''
+                                                  -- Unknown         */
+ #include "pth_p.h"
+ 
+ #if cpp
+ 
+ #if PTH_SYSCALL_HARD
+ #include <sys/syscall.h>
+ #ifdef HAVE_SYS_SOCKETCALL_H
+ #include <sys/socketcall.h>
+ #endif
+ #define pth_sc(func) PTH_SC_##func
+ #else
+ #define pth_sc(func) func
+ #endif
+ 
+ #endif /* cpp */
+ 
+ /* some exported variables for object layer checks */
+ int pth_syscall_soft = PTH_SYSCALL_SOFT;
+ int pth_syscall_hard = PTH_SYSCALL_HARD;
+ 
+ /* Pth hard wrapper for syscall fork(2) */
+ #if cpp
+ #if defined(SYS_fork)
+ #define PTH_SC_fork() ((pid_t)syscall(SYS_fork))
+ #else
+ #define PTH_SC_fork fork
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_fork)
+ pid_t fork(void)
+ {
+     pth_implicit_init();
+     return pth_fork();
+ }
+ #endif
+ 
+ /* Pth hard wrapper for sleep(3) [internally fully emulated] */
+ #if PTH_SYSCALL_HARD
+ unsigned int sleep(unsigned int sec)
+ {
+     pth_implicit_init();
+     return pth_sleep(sec);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for system(3) [internally fully emulated] */
+ #if PTH_SYSCALL_HARD
+ int system(const char *cmd)
+ {
+     pth_implicit_init();
+     return pth_system(cmd);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for sigprocmask(2) */
+ #if cpp
+ #if defined(SYS_sigprocmask)
+ #define PTH_SC_sigprocmask(a1,a2,a3) ((int)syscall(SYS_sigprocmask,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_sigprocmask sigprocmask
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_sigprocmask)
+ int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
+ {
+     pth_implicit_init();
+     return pth_sigmask(how, set, oset);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for sigwait(3) [internally fully emulated] */
+ #if PTH_SYSCALL_HARD
+ int sigwait(const sigset_t *set, int *sigp)
+ {
+     pth_implicit_init();
+     return pth_sigwait(set, sigp);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall waitpid(2) */
+ #if cpp
+ #if defined(SYS_waitpid)
+ #define PTH_SC_waitpid(a1,a2,a3) ((int)syscall(SYS_waitpid,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_waitpid waitpid
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_waitpid)
+ pid_t waitpid(pid_t wpid, int *status, int options)
+ {
+     pth_implicit_init();
+     return pth_waitpid(wpid, status, options);
+ }
+ #endif
+ 
+ #if defined(SYS_socketcall) && defined(SOCKOP_connect) && defined(SOCKOP_accept) /* mainly Linux */
+ intern int _pth_socketcall(int call, ...)
+ {
+     va_list ap;
+     unsigned long args[3];
+ 
+     va_start(ap, call);
+     switch (call) {
+         case SOCKOP_connect:
+             args[0] = (unsigned long)va_arg(ap, int);
+             args[1] = (unsigned long)va_arg(ap, struct sockaddr *);
+             args[2] = (unsigned long)va_arg(ap, int);
+             break;
+         case SOCKOP_accept:
+             args[0] = (unsigned long)va_arg(ap, int);
+             args[1] = (unsigned long)va_arg(ap, struct sockaddr *);
+             args[2] = (unsigned long)va_arg(ap, int *);
+             break;
+     }
+     va_end(ap);
+     return syscall(SYS_socketcall, call, args);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall connect(2) */
+ #if cpp
+ #if defined(SYS_connect)
+ #define PTH_SC_connect(a1,a2,a3) ((int)syscall(SYS_connect,(a1),(a2),(a3)))
+ #elif defined(SYS_socketcall) && defined(SOCKOP_connect) /* mainly Linux */
+ #define PTH_SC_connect(a1,a2,a3) ((int)_pth_socketcall(SOCKOP_connect,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_connect connect
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD &&\
+     (defined(SYS_connect) || (defined(SYS_socketcall) && defined(SOCKOP_connect)))
+ int connect(int s, const struct sockaddr *addr, socklen_t addrlen)
+ {
+     pth_implicit_init();
+     return pth_connect(s, addr, addrlen);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall accept(2) */
+ #if cpp
+ #if defined(SYS_accept)
+ #define PTH_SC_accept(a1,a2,a3) ((int)syscall(SYS_accept,(a1),(a2),(a3)))
+ #elif defined(SYS_socketcall) && defined(SOCKOP_accept) /* mainly Linux */
+ #define PTH_SC_accept(a1,a2,a3) ((int)_pth_socketcall(SOCKOP_accept,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_accept accept
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD &&\
+     (defined(SYS_accept) || (defined(SYS_socketcall) && defined(SOCKOP_accept)))
+ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
+ {
+     pth_implicit_init();
+     return pth_accept(s, addr, addrlen);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall select(2) */
+ #if cpp
+ #if defined(SYS__newselect) /* mainly Linux */
+ #define PTH_SC_select(a1,a2,a3,a4,a5) ((int)syscall(SYS__newselect,(a1),(a2),(a3),(a4),(a5)))
+ #elif defined(SYS_select)
+ #define PTH_SC_select(a1,a2,a3,a4,a5) ((int)syscall(SYS_select,(a1),(a2),(a3),(a4),(a5)))
+ #else
+ #define PTH_SC_select select
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && (defined(SYS__newselect) || defined(SYS_select))
+ int select(int nfds, fd_set *readfds, fd_set *writefds,
+            fd_set *exceptfds, struct timeval *timeout)
+ {
+     pth_implicit_init();
+     return pth_select(nfds, readfds, writefds, exceptfds, timeout);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall poll(2) */
+ #if cpp
+ #if defined(SYS_poll)
+ #define PTH_SC_poll(a1,a2,a3) ((int)syscall(SYS_poll,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_poll poll
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_poll)
+ int poll(struct pollfd *pfd, nfds_t nfd, int timeout)
+ {
+     pth_implicit_init();
+     return pth_poll(pfd, nfd, timeout);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall read(2) */
+ #if cpp
+ #if defined(SYS_read)
+ #define PTH_SC_read(a1,a2,a3) ((ssize_t)syscall(SYS_read,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_read read
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_read)
+ ssize_t read(int fd, void *buf, size_t nbytes)
+ {
+     pth_implicit_init();
+     return pth_read(fd, buf, nbytes);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall write(2) */
+ #if cpp
+ #if defined(SYS_write)
+ #define PTH_SC_write(a1,a2,a3) ((ssize_t)syscall(SYS_write,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_write write
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_write)
+ ssize_t write(int fd, const void *buf, size_t nbytes)
+ {
+     pth_implicit_init();
+     return pth_write(fd, buf, nbytes);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall readv(2) */
+ #if cpp
+ #if defined(SYS_readv)
+ #define PTH_SC_readv(a1,a2,a3) ((ssize_t)syscall(SYS_readv,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_readv readv
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_readv)
+ ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
+ {
+     pth_implicit_init();
+     return pth_readv(fd, iov, iovcnt);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall writev(2) */
+ #if cpp
+ #if defined(SYS_writev)
+ #define PTH_SC_writev(a1,a2,a3) ((ssize_t)syscall(SYS_writev,(a1),(a2),(a3)))
+ #else
+ #define PTH_SC_writev writev
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_writev)
+ ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+ {
+     pth_implicit_init();
+     return pth_writev(fd, iov, iovcnt);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for pread(3) [internally fully emulated] */
+ #if PTH_SYSCALL_HARD
+ ssize_t pread(int, void *, size_t, off_t);
+ ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset)
+ {
+     pth_implicit_init();
+     return pth_pread(fd, buf, nbytes, offset);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for pwrite(3) [internally fully emulated] */
+ #if PTH_SYSCALL_HARD
+ ssize_t pwrite(int, const void *, size_t, off_t);
+ ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset)
+ {
+     pth_implicit_init();
+     return pth_pwrite(fd, buf, nbytes, offset);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall recvfrom(2) */
+ #if cpp
+ #if defined(SYS_recvfrom)
+ #define PTH_SC_recvfrom(a1,a2,a3,a4,a5,a6) ((ssize_t)syscall(SYS_recvfrom,(a1),(a2),(a3),(a4),(a5),(a6)))
+ #else
+ #define PTH_SC_recvfrom recvfrom
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_recvfrom)
+ ssize_t recvfrom(int fd, void *buf, size_t nbytes, int flags, struct sockaddr *from, socklen_t *fromlen)
+ {
+     pth_implicit_init();
+     return pth_recvfrom(fd, buf, nbytes, flags, from, fromlen);
+ }
+ #endif
+ 
+ /* Pth hard wrapper for syscall sendto(2) */
+ #if cpp
+ #if defined(SYS_sendto)
+ #define PTH_SC_sendto(a1,a2,a3,a4,a5,a6) ((ssize_t)syscall(SYS_sendto,(a1),(a2),(a3),(a4),(a5),(a6)))
+ #else
+ #define PTH_SC_sendto sendto
+ #endif
+ #endif /* cpp */
+ #if PTH_SYSCALL_HARD && defined(SYS_sendto)
+ ssize_t sendto(int fd, const void *buf, size_t nbytes, int flags, const struct sockaddr *to, socklen_t tolen)
+ {
+     pth_implicit_init();
+     return pth_sendto(fd, buf, nbytes, flags, to, tolen);
+ }
+ #endif
+ 

CVSTrac 2.0.1