Index: ossp-pkg/pth/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/pth/ChangeLog,v rcsdiff -q -kk '-r1.531' '-r1.532' -u '/v/ossp/cvs/ossp-pkg/pth/ChangeLog,v' 2>/dev/null --- 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 ] Index: ossp-pkg/pth/configure.in RCS File: /v/ossp/cvs/ossp-pkg/pth/Attic/configure.in,v co -q -kk -p'1.119' '/v/ossp/cvs/ossp-pkg/pth/Attic/configure.in,v' | diff -u - /dev/null -L'ossp-pkg/pth/configure.in' 2>/dev/null --- ossp-pkg/pth/configure.in +++ /dev/null 2024-05-17 18:15:40.000000000 +0200 @@ -1,607 +0,0 @@ -dnl ## -dnl ## GNU Pth - The GNU Portable Threads -dnl ## Copyright (c) 1999-2000 Ralf S. Engelschall -dnl ## -dnl ## This file is part of GNU Pth, a non-preemptive thread scheduling -dnl ## library which can be found at http://www.gnu.org/software/pth/. -dnl ## -dnl ## This library is free software; you can redistribute it and/or -dnl ## modify it under the terms of the GNU Lesser General Public -dnl ## License as published by the Free Software Foundation; either -dnl ## version 2.1 of the License, or (at your option) any later version. -dnl ## -dnl ## This library is distributed in the hope that it will be useful, -dnl ## but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl ## Lesser General Public License for more details. -dnl ## -dnl ## You should have received a copy of the GNU Lesser General Public -dnl ## License along with this library; if not, write to the Free Software -dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -dnl ## USA, or contact Ralf S. Engelschall . -dnl ## -dnl ## configure.in: Pth Autoconf specification -dnl ## - -dnl # ``Programming in Bourne-Shell -dnl # is a higher form of masochism.'' -dnl # -- Unknown - -dnl ## -dnl ## PROLOG -dnl ## - -dnl # standard Autoconf prolog -AC_PREREQ(2.12)dnl -AC_REVISION([1.0]) - -dnl # autoconf initialization -AC_INIT(README) -AC_ENABLESUBDIR -AC_SRCDIR_PREFIX(srcdir_prefix) -AC_HEADLINE(dnl -GNU Pth, Portable Threads, dnl -PTH_VERSION, pth_vers.c, dnl -[Copyright (c) 1999-2000 Ralf S. Engelschall ]) -AC_CONFIG_PARAM(config.param) -AC_CONFIG_HEADER(pth_acdef.h)dnl -AC_PREFIX_DEFAULT(/usr/local) -AC_PLATFORM(PLATFORM) - -dnl ## -dnl ## BUILD TOOLS -dnl ## - -AC_MSG_PART(Build Tools) - -AC_PROG_CC -AC_PROG_CPP -AC_SET_MAKE -AC_CHECK_DEBUGGING -AC_CHECK_PROFILING -AC_CHECK_OPTIMIZE -if test -f "$srcdir/ltconfig"; then - AC_PROG_LIBTOOL($PLATFORM) -else - dnl # only for stripped down Pth source tree - AC_CHECK_PROG(AR, ar, ar) - AC_PROG_RANLIB -fi - -dnl ## Support for some special platform/compiler options -case "$PLATFORM:$CC" in - *-sun-solaris2*:cc ) - # shut-up harmless warnings caused by do-while macros on Solaris - test ".$ac_cv_prog_gcc" = ".no" && CFLAGS="$CFLAGS -w" - ;; - *-*-sysv*uw[[27]]*:cc ) - # shut-up harmless warnings caused by do-while macros on UnixWare - CFLAGS="$CFLAGS -w" - ;; - *-hp-hpux*:cc ) - # HPUX needs a few special options to find its ANSI C brain - CFLAGS="$CFLAGS -Ae -O" - ;; - *-hp-hpux*:CC ) - # HPUX outputs useless warnings - CFLAGS="$CFLAGS -w" - ;; - *-sgi-irix6.2:cc ) - # shut-up warnings caused by IRIX brain-dead 32/64 bit stuff - LDFLAGS="$LDFLAGS -woff 85 -Wl,-woff,84 -Wl,-woff,85" - ;; - *-sgi-irix6.5.[[2-9]]:cc ) - # since IRIX 6.5.2 the C compiler is smart enough, - # but the linker is still complaining, of course - LDFLAGS="$LDFLAGS -woff 84,85,134" - ;; - *-sgi-irix6.5:cc ) - # shut-up warnings caused by IRIX brain-dead 32/64 bit stuff - CFLAGS="$CFLAGS -woff 1110,1048" - LDFLAGS="$LDFLAGS -woff 84,85,134" - ;; - *-dec-osf4*:cc ) - # make sure the standard compliant functions are used on Tru64/OSF1 4.x - CFLAGS="$CFLAGS -std" - ;; - *-dec-osf5*:cc ) - # make sure the standard compliant functions are used on Tru64/OSF1 5.x - CFLAGS="$CFLAGS -std -D_XOPEN_SOURCE_EXTENDED" - ;; - *-*-isc*:* ) - # ISC is brain-dead and needs a bunch of options to find its brain - CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE"; - LIBS="$LIBS -lcposix -linet"; - ;; -esac - -dnl ## -dnl ## MANDATORY PLATFORM ENVIRONMENT -dnl ## - -AC_MSG_PART(Mandatory Platform Environment) - -dnl # check for standard headers -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) -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 - func:gettimeofday func:select func:sigaction func:sigprocmask dnl - func:sigpending func:sigsuspend, - AC_DECIDE(fine, [all fine])) -AC_END_DECISION - - -dnl ## -dnl ## OPTIONAL PLATFORM ENVIRONMENT -dnl ## - -AC_MSG_PART(Optional Platform Environment) - -dnl # check for the number of signals -AC_CHECK_NSIG(PTH_NSIG) - -dnl # check whether poll(2)'s input stuff has to be faked -AC_CHECK_FUNCTIONS(poll) -AC_CHECK_DEFINE(POLLIN, poll.h) -AC_MSG_CHECKING(whether poll(2) facility has to be faked) -AC_IFALLYES(func:poll define:POLLIN, PTH_FAKE_POLL=0, PTH_FAKE_POLL=1) -if test .$PTH_FAKE_POLL = .1; then - msg="yes" -else - msg="no" -fi -AC_SUBST(PTH_FAKE_POLL) -AC_MSG_RESULT([$msg]) - -dnl # check for readv/writev environment -AC_HAVE_HEADERS(sys/uio.h) -AC_CHECK_FUNCTIONS(readv writev) -AC_MSG_CHECKING(whether readv(2)/writev(2) facility has to be faked) -AC_IFALLYES(func:readv func:writev header:sys/uio.h, PTH_FAKE_RWV=0, PTH_FAKE_RWV=1) -if test .$PTH_FAKE_RWV = .1; then - msg="yes" -else - msg="no" -fi -AC_SUBST(PTH_FAKE_RWV) -AC_MSG_RESULT([$msg]) - -dnl # check for various other functions which would be nice to have -AC_CHECK_FUNCTIONS(usleep strerror) - -dnl # check for various other headers which we might need -AC_HAVE_HEADERS(sys/resource.h net/errno.h) - -dnl # at least the test programs need some socket stuff -AC_CHECK_LIB(nsl, gethostname) -if test ".`echo $LIBS | grep nsl`" = . ;then - AC_CHECK_LIB(nsl, gethostbyname) -fi -AC_CHECK_LIB(socket, accept) - -dnl # check whether we've to use a non-standard #include to get -dnl # the definition for fd_set under AIX and other brain-dead platforms. -AC_HAVE_HEADERS(sys/select.h) -EXTRA_INCLUDE_SYS_SELECT_H="#include " -if test ".$ac_cv_header_sys_select_h" != .yes; then - EXTRA_INCLUDE_SYS_SELECT_H="/* $EXTRA_INCLUDE_SYS_SELECT_H */" -fi -AC_SUBST(EXTRA_INCLUDE_SYS_SELECT_H) - -dnl # check whether we've to define sig_atomic_t -AC_CHECK_TYPEDEF(sig_atomic_t, signal.h) -FALLBACK_SIG_ATOMIC_T="typedef int sig_atomic_t;" -if test ".$ac_cv_typedef_sig_atomic_t" = .yes; then - FALLBACK_SIG_ATOMIC_T="/* $FALLBACK_SIG_ATOMIC_T */" -fi -AC_SUBST(FALLBACK_SIG_ATOMIC_T) - -dnl # check whether we've to define pid_t -AC_CHECK_TYPEDEF(pid_t, sys/types.h) -FALLBACK_PID_T="typedef int pid_t;" -if test ".$ac_cv_typedef_pid_t" = .yes; then - FALLBACK_PID_T="/* $FALLBACK_PID_T */" -fi -AC_SUBST(FALLBACK_PID_T) - -dnl # check whether we've to define size_t -AC_CHECK_TYPEDEF(size_t, stdlib.h) -FALLBACK_SIZE_T="typedef unsigned int size_t;" -if test ".$ac_cv_typedef_size_t" = .yes; then - FALLBACK_SIZE_T="/* $FALLBACK_SIZE_T */" -fi -AC_SUBST(FALLBACK_SIZE_T) - -dnl # check whether we've to define ssize_t -AC_CHECK_TYPEDEF(ssize_t, sys/types.h) -FALLBACK_SSIZE_T="typedef unsigned int ssize_t;" -if test ".$ac_cv_typedef_ssize_t" = .yes; then - FALLBACK_SSIZE_T="/* $FALLBACK_SSIZE_T */" -fi -AC_SUBST(FALLBACK_SSIZE_T) - -dnl # check whether we've to define off_t -AC_CHECK_TYPEDEF(off_t, sys/types.h) -FALLBACK_OFF_T="typedef int off_t;" -if test ".$ac_cv_typedef_off_t" = .yes; then - FALLBACK_OFF_T="/* $FALLBACK_OFF_T */" -fi -AC_SUBST(FALLBACK_OFF_T) - -dnl # check whether stack_t exists instead of sigaltstack -AC_CHECK_TYPEDEF(stack_t, signal.h) - -dnl # check whether ss_base instead of ss_sp attribute exists -AC_CHECK_STRUCTATTR(ss_base, sigaltstack, sys/signal.h) -AC_CHECK_STRUCTATTR(ss_sp, sigaltstack, sys/signal.h) - -dnl # check for gettimeofday() variant -AC_MSG_CHECKING(for a single-argument based gettimeofday) -cross_compile=no -AC_TRY_COMPILE([ -#include -#include -#include -],[ -struct timeval tv; -(void)gettimeofday(&tv); -], -msg="yes" -, -msg="no" -) -case $PLATFORM in - *-*-aix4* ) msg="no" ;; # on AIX the compiler test doesn't work - *-*-isc* ) msg="no" ;; # on ISC the compiler test doesn't work -esac -if test ".$msg" = .yes; then - AC_DEFINE(HAVE_GETTIMEOFDAY_ARGS1) -fi -AC_MSG_RESULT([$msg]) - -dnl # check for struct timespec -AC_MSG_CHECKING(for struct timespec) -cross_compile=no -AC_TRY_COMPILE([ -#include -#include -],[ -struct timespec ts; -], -msg="yes" -, -msg="no" -) -if test ".$msg" = .yes; then - AC_DEFINE(HAVE_STRUCT_TIMESPEC) -fi -AC_MSG_RESULT([$msg]) - -dnl # check for network/socket size type -AC_CHECK_SOCKLENTYPE([ -FALLBACK_SOCKLEN_T="typedef ${ac_type} socklen_t;" -if test ".$ac_type" = ".socklen_t"; then - FALLBACK_SOCKLEN_T="/* $FALLBACK_SOCKLEN_T */" -fi -AC_SUBST(FALLBACK_SOCKLEN_T) -]) - -dnl # check for filedescriptor number type -AC_CHECK_NFDSTYPE([ -FALLBACK_NFDS_T="typedef ${ac_type} nfds_t;" -if test ".$ac_type" = ".nfds_t"; then - FALLBACK_NFDS_T="/* $FALLBACK_NFDS_T */" -fi -AC_SUBST(FALLBACK_NFDS_T) -]) - -dnl # check for 64-bit types (for pth_snprintf.c) -AC_CHECK_LONGLONG -AC_CHECK_LONGDOUBLE - -dnl ## -dnl ## MACHINE CONTEXT IMPLEMENTATION -dnl ## - -AC_MSG_PART(Machine Context Implementation) - -dnl # -dnl # 1. determine possibilities -dnl # - -dnl # check for MCSC method -AC_CHECK_HEADERS(ucontext.h) -AC_CHECK_FUNCTIONS(makecontext swapcontext getcontext setcontext) -AC_CHECK_MCSC(mcsc=yes, mcsc=no) - -dnl # check for SJLJ method -AC_CHECK_HEADERS(signal.h) -AC_CHECK_FUNCTIONS(sigsetjmp siglongjmp setjmp longjmp _setjmp _longjmp) -AC_CHECK_FUNCTIONS(sigaltstack sigstack) -AC_CHECK_SJLJ(sjlj=yes, sjlj=no, sjlj_type) - -dnl # -dnl # 2. make a general decision -dnl # - -if test ".$mcsc" = .yes; then - mctx_mth=mcsc - mctx_dsp=sc - mctx_stk=mc -elif test ".$sjlj" = .yes; then - mctx_mth=sjlj - mctx_dsp=$sjlj_type - mctx_stk=none - AC_IFALLYES(func:sigstack, mctx_stk=ss) - AC_IFALLYES(func:sigaltstack, mctx_stk=sas) - case $mctx_dsp in - sjljlx|sjljisc|sjljw32 ) mctx_stk=none - esac -else - AC_ERROR([no appropriate mctx method found]) -fi - -dnl # -dnl # 3. allow decision to be overridden by user -dnl # - -AC_ARG_WITH(mctx-mth,dnl -[ --with-mctx-mth=ID force mctx method (mcsc,sjlj)],[ -case $withval in - mcsc|sjlj ) mctx_mth=$withval ;; - * ) AC_ERROR([invalid mctx method -- allowed: mcsc,sjlj]) ;; -esac -])dnl -AC_ARG_WITH(mctx-dsp,dnl -[ --with-mctx-dsp=ID force mctx dispatching (sc,ssjlj,sjlj,usjlj,sjlje,...)],[ -case $withval in - sc|ssjlj|sjlj|usjlj|sjlje|sjljlx|sjljisc|sjljw32 ) mctx_dsp=$withval ;; - * ) AC_ERROR([invalid mctx dispatching -- allowed: sc,ssjlj,sjlj,usjlj,sjlje,sjljlx,sjljisc,sjljw32]) ;; -esac -])dnl -AC_ARG_WITH(mctx-stk,dnl -[ --with-mctx-stk=ID force mctx stack setup (mc,ss,sas,...)],[ -case $withval in - mc|ss|sas|none ) mctx_stk=$withval ;; - * ) AC_ERROR([invalid mctx stack setup -- allowed: mc,ss,sas,none]) ;; -esac -])dnl - -dnl # -dnl # 4. determine a few additional details -dnl # - -dnl # whether sigaltstack has to use stack_t instead of struct sigaltstack -AC_CHECK_TYPEDEF(stack_t, signal.h) - -dnl # direction of stack grow -AC_CHECK_STACKGROWTH(PTH_STACKGROWTH) -if test ".$ac_cv_check_stackgrowth" = ".down"; then - PTH_STACK_GROWTH="down" -else - PTH_STACK_GROWTH="up" -fi -AC_SUBST(PTH_STACK_GROWTH) - -dnl # how to specify stacks for the various functions -AC_CHECK_STACKSETUP(makecontext, pth_skaddr_makecontext, pth_sksize_makecontext) -AC_CHECK_STACKSETUP(sigaltstack, pth_skaddr_sigaltstack, pth_sksize_sigaltstack) -AC_CHECK_STACKSETUP(sigstack, pth_skaddr_sigstack, pth_sksize_sigstack) - -dnl # how to implement POSIX compliant sig{set,long}jmp() -case $mctx_dsp in [ - ssjlj ) - pth_sigjmpbuf='sigjmp_buf' - pth_sigsetjmp='sigsetjmp(buf,1)' - pth_siglongjmp='siglongjmp(buf,val)' - ;; - sjlj ) - pth_sigjmpbuf='jmp_buf' - pth_sigsetjmp='setjmp(buf)' - pth_siglongjmp='longjmp(buf,val)' - ;; - usjlj ) - pth_sigjmpbuf='jmp_buf' - pth_sigsetjmp='_setjmp(buf)' - pth_siglongjmp='_longjmp(buf,val)' - ;; - sjlje ) - pth_sigjmpbuf='jmp_buf' - pth_sigsetjmp='setjmp(buf)' - pth_siglongjmp='longjmp(buf,val)' - ;; - sjljlx|sjljisc|sjljw32 ) - pth_sigjmpbuf='sigjmp_buf' - pth_sigsetjmp='sigsetjmp(buf,1)' - pth_siglongjmp='siglongjmp(buf,val)' - ;; -] esac -pth_sigjmpbuf="#define pth_sigjmpbuf $pth_sigjmpbuf" -pth_sigsetjmp="#define pth_sigsetjmp(buf) $pth_sigsetjmp" -pth_siglongjmp="#define pth_siglongjmp(buf,val) $pth_siglongjmp" -AC_SUBST(pth_sigjmpbuf) -AC_SUBST(pth_sigsetjmp) -AC_SUBST(pth_siglongjmp) - -dnl # -dnl # 5. export the results -dnl # - -AC_DEFINE_UNQUOTED(PTH_MCTX_MTH_use, [PTH_MCTX_MTH_$mctx_mth]) -AC_DEFINE_UNQUOTED(PTH_MCTX_DSP_use, [PTH_MCTX_DSP_$mctx_dsp]) -AC_DEFINE_UNQUOTED(PTH_MCTX_STK_use, [PTH_MCTX_STK_$mctx_stk]) - -PTH_MCTX_ID="$mctx_mth/$mctx_dsp/$mctx_stk" -AC_MSG_RESULT([decision on mctx implementation... ${TB}${PTH_MCTX_ID}${TN}]) -AC_SUBST(PTH_MCTX_ID) - -AC_MSG_VERBOSE([decided mctx method: $mctx_mth]) -AC_MSG_VERBOSE([decided mctx dispatching: $mctx_dsp]) -AC_MSG_VERBOSE([decided mctx stack setup: $mctx_stk]) - - -dnl ## -dnl ## SYSTEM CALL MAPPING -dnl ## - -AC_MSG_PART(System Call Mapping) - -AC_CHECK_FUNCTIONS(syscall) -AC_CHECK_HEADERS(sys/syscall.h sys/socketcall.h) -AC_CHECK_DEFINE(SYS_read, sys/syscall.h) - -AC_MSG_CHECKING([whether soft system call mapping is used]) -AC_ARG_ENABLE(syscall-soft,dnl -[ --enable-syscall-soft enable soft system call mapping (default=no)], -enable_syscall_soft="$enableval", -if test ".$enable_syscall_soft" = .; then - enable_syscall_soft=no -fi -)dnl -if test .$enable_syscall_soft = .yes; then - PTH_SYSCALL_SOFT=1 - msg="yes" -else - PTH_SYSCALL_SOFT=0 - msg="no" -fi -AC_MSG_RESULT([$msg]) -AC_SUBST(PTH_SYSCALL_SOFT) - -AC_MSG_CHECKING([whether hard system call mapping is used]) -AC_ARG_ENABLE(syscall-hard,dnl -[ --enable-syscall-hard enable hard system call mapping (default=no)], -enable_syscall_hard="$enableval",[ -if test ".$enable_syscall_hard" = .; then - enable_syscall_hard=no -fi -])dnl -if test ".$enable_syscall_hard" = .yes; then - AC_IFALLYES(func:syscall header:sys/syscall.h define:SYS_read, - enable_syscall_hard=yes, enable_syscall_hard=no) -fi -if test ".$enable_syscall_hard" = .yes; then - PTH_SYSCALL_HARD=1 - msg="yes" -else - PTH_SYSCALL_HARD=0 - msg="no" -fi -AC_MSG_RESULT([$msg]) -AC_SUBST(PTH_SYSCALL_HARD) -if test ".$enable_syscall_hard" = .yes; then - echo "${TB}Warning: The hard system call mapping variant is still work in progress.${TN}" - echo "${TB} Do neither expect it to compile on all platforms (because of${TN}" - echo "${TB} conflicts with vendor prototypes) nor to actually work!${TN}" -fi - - -dnl ## -dnl ## BUILD PARAMETERS -dnl ## - -AC_MSG_PART(Build Parameters) - -dnl # check for various build parameters -AC_CHECK_BUILDPARAM - -dnl # whether to build Pthread library -AC_MSG_CHECKING(whether to build Pthread library) -AC_ARG_ENABLE(pthread,dnl -[ --enable-pthread build Pthread library (default=no)], -enable_pthread="$enableval", -if test ".$enable_pthread" = .; then - enable_pthread=no -fi -)dnl -AC_MSG_RESULT([$enable_pthread]) -if test ".$enable_pthread" = .yes; then - PTHREAD_O=pthread.o dnl # only for stripped down Pth source tree - LIBPTHREAD_A=libpthread.a dnl # only for stripped down Pth source tree - LIBPTHREAD_LA=libpthread.la - PTHREAD_CONFIG_1='$(S)pthread-config.1' - PTHREAD_3='$(S)pthread.3' - INSTALL_PTHREAD=install-pthread - UNINSTALL_PTHREAD=uninstall-pthread - TEST_PTHREAD=test_pthread - enable_syscall_soft=yes - AC_HAVE_HEADERS(pthread.h) - ac_warn=no - if test ".$ac_cv_header_pthread_h" = .yes; then - warn=yes - changequote(<<,>>) - case $PLATFORM in - *-*-freebsd* ) ac_warn=no ;; - *-*-linux* ) ac_warn=no ;; - *-*-solaris* ) ac_warn=no ;; - *-*-irix* ) ac_warn=no ;; - esac - changequote([,]) - fi - if test ".$ac_warn" = .yes; then - echo "${TB}Warning: You seem to have a vendor Pthread library installed.${TN}" - echo "${TB} There might be conflicts with its pthread.h under compile-time!${TN}" - fi -else - PTHREAD_O="" dnl # only for stripped down Pth source tree - LIBPTHREAD_A="" dnl # only for stripped down Pth source tree - LIBPTHREAD_LA="" - PTHREAD_CONFIG_1="" - PTHREAD_3="" - INSTALL_PTHREAD="" - UNINSTALL_PTHREAD="" - TEST_PTHREAD="" -fi -AC_SUBST(PTHREAD_O) -AC_SUBST(LIBPTHREAD_A) -AC_SUBST(LIBPTHREAD_LA) -AC_SUBST(PTHREAD_CONFIG_1) -AC_SUBST(PTHREAD_3) -AC_SUBST(INSTALL_PTHREAD) -AC_SUBST(UNINSTALL_PTHREAD) -AC_SUBST(TEST_PTHREAD) - -dnl # whether to build against Sfio library -PTH_EXT_SFIO=FALSE -AC_CHECK_EXTLIB(Sfio, sfio, sfdisc, sfio.h, PTH_EXT_SFIO=TRUE) -AC_SUBST(PTH_EXT_SFIO) - -dnl # whether to build against Dmalloc library -AC_CHECK_EXTLIB(Dmalloc, dmalloc, dmalloc_debug, dmalloc.h, AC_DEFINE(PTH_DMALLOC)) - -dnl ## -dnl ## OUTPUT SUBSTITUTION -dnl ## - -AC_MSG_PART(Output Substitution) - -AC_OUTPUT(dnl -Makefile dnl -pthread-config dnl -pthread.h dnl -pth-config dnl -pth.h dnl -pth_acmac.h dnl -,dnl -chmod +rx pthread-config -chmod +rx pth-config -)dnl -if test ".$enable_pthread" = .no; then - rm -f pthread-config - rm -f pthread.h -fi - -if test ".$enable_batch" != .yes; then - echo "" - echo "Now please type \`${TB}make${TN}' to compile. Good luck." - echo "" -fi - Index: ossp-pkg/pth/pth.h.in RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.h.in,v co -q -kk -p'1.127' '/v/ossp/cvs/ossp-pkg/pth/pth.h.in,v' | diff -u /dev/null - -L'ossp-pkg/pth/pth.h.in' 2>/dev/null --- ossp-pkg/pth/pth.h.in +++ - 2024-05-17 18:19:53.458935073 +0200 @@ -0,0 +1,525 @@ +/* +** GNU Pth - The GNU Portable Threads +** Copyright (c) 1999-2000 Ralf S. Engelschall +** +** 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 . +** +** 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 /* for ssize_t, off_t */ +#include /* for struct timeval */ +#include /* for sockaddr */ +#include /* 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 +#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 +#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 +#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_ */ + Index: ossp-pkg/pth/pth.pod RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.pod,v rcsdiff -q -kk '-r1.142' '-r1.143' -u '/v/ossp/cvs/ossp-pkg/pth/pth.pod,v' 2>/dev/null --- 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(const char *I); + +This is a variant of the POSIX system(3) function. It executes the +shell command I with Bourne Shell (C) 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(int I, const sigset_t *I, sigset_t *I) This is the B thread-related equivalent of POSIX sigprocmask(2) respectively @@ -2128,8 +2138,8 @@ building B with C<--enable-syscall-soft>. This then triggers some C<#define>'s in the C 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 with C<--enable-syscall-hard>. This then builds wrapper functions (for instances read(3)) into the B library which internally call the real B -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 Index: ossp-pkg/pth/pth_acdef.h.in RCS File: /v/ossp/cvs/ossp-pkg/pth/Attic/pth_acdef.h.in,v co -q -kk -p'1.15' '/v/ossp/cvs/ossp-pkg/pth/Attic/pth_acdef.h.in,v' | diff -u /dev/null - -L'ossp-pkg/pth/pth_acdef.h.in' 2>/dev/null --- ossp-pkg/pth/pth_acdef.h.in +++ - 2024-05-17 18:19:53.471528836 +0200 @@ -0,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 +** +** 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 . +** +** 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 header file. */ +#undef HAVE_DMALLOC_H + +/* Define if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_NET_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_PATHS_H + +/* Define if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define if you have the header file. */ +#undef HAVE_SETJMP_H + +/* Define if you have the header file. */ +#undef HAVE_SFIO_H + +/* Define if you have the header file. */ +#undef HAVE_SIGNAL_H + +/* Define if you have the header file. */ +#undef HAVE_STDARG_H + +/* Define if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_RESOURCE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SOCKETCALL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SYSCALL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_UIO_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define if you have the header file. */ +#undef HAVE_UCONTEXT_H + +/* Define if you have the 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_ */ + Index: ossp-pkg/pth/pth_fork.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_fork.c,v co -q -kk -p'1.11' '/v/ossp/cvs/ossp-pkg/pth/pth_fork.c,v' | diff -u /dev/null - -L'ossp-pkg/pth/pth_fork.c' 2>/dev/null --- ossp-pkg/pth/pth_fork.c +++ - 2024-05-17 18:19:53.474272439 +0200 @@ -0,0 +1,99 @@ +/* +** GNU Pth - The GNU Portable Threads +** Copyright (c) 1999-2000 Ralf S. Engelschall +** +** 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 . +** +** 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; +} + Index: ossp-pkg/pth/pth_high.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_high.c,v rcsdiff -q -kk '-r1.74' '-r1.75' -u '/v/ossp/cvs/ossp-pkg/pth/pth_high.c,v' 2>/dev/null --- 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) { Index: ossp-pkg/pth/pth_p.h.in RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_p.h.in,v rcsdiff -q -kk '-r1.26' '-r1.27' -u '/v/ossp/cvs/ossp-pkg/pth/pth_p.h.in,v' 2>/dev/null --- 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 #include #include +#include #include /* library version */ @@ -69,6 +70,16 @@ #include #endif +/* paths */ +#ifdef HAVE_PATHS_H +#include +#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 Index: ossp-pkg/pth/pth_syscall.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_syscall.c,v co -q -kk -p'1.20' '/v/ossp/cvs/ossp-pkg/pth/pth_syscall.c,v' | diff -u /dev/null - -L'ossp-pkg/pth/pth_syscall.c' 2>/dev/null --- ossp-pkg/pth/pth_syscall.c +++ - 2024-05-17 18:19:53.487479448 +0200 @@ -0,0 +1,337 @@ +/* +** GNU Pth - The GNU Portable Threads +** Copyright (c) 1999-2000 Ralf S. Engelschall +** +** 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 . +** +** 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 +#ifdef HAVE_SYS_SOCKETCALL_H +#include +#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 +