head 1.147; access; symbols PTH_2_0_7:1.146 PTH_2_0_6:1.145 PTH_2_0_5:1.145 PTH_2_0_4:1.145 PTH_2_0_3:1.144 PTH_2_0_2:1.142 PTH_2_0_1:1.141 PTH_2_0_0:1.140 PTH_2_0b2:1.139 PTH_2_0b1:1.139 PTH_2_0b0:1.138 PTH_1_4:1.131.0.2 PTH_1_4_1:1.131 PTH_1_4_0:1.129 PTH_1_3_7:1.123.2.1 PTH_1_4a3:1.126 PTH_1_3_6:1.123.2.1 PTH_1_4a2:1.126 PTH_1_3_5:1.123.2.1 PTH_1_4a1:1.126 PTH_1_3_4:1.123.2.1 PTH_1_3:1.123.0.2 PTH_1_3_3:1.123 PTH_1_3_2:1.121 PTH_1_3_1:1.121 PTH_1_3_0:1.121 PTH_1_3b3:1.121 PTH_1_2_3:1.111.2.2 PTH_1_3b2:1.120 PTH_1_3b1:1.118 PTH_1_3a5:1.118 PTH_1_3a4:1.118 PTH_1_3a3:1.118 PTH_1_2_2:1.111.2.2 PTH_1_3a2:1.117 PTH_1_2_1:1.111.2.1 PTH_1_3a1:1.114 PTH_1_2:1.111.0.2 PTH_1_2_0:1.111 PTH_1_2b8:1.110 PTH_1_2b7:1.109 PTH_1_1_6:1.104.2.1 PTH_1_2b6:1.108 PTH_1_2b5:1.108 PTH_1_2b4:1.108 PTH_1_2b3:1.108 PTH_1_2b2:1.107 PTH_1_2b1:1.107 PTH_1_1_5:1.104.2.1 PTH_1_0_6:1.96 PTH_1_0_5:1.96 PTH_1_0:1.96.0.2 PTH_1_1:1.104.0.2 PTH_1_1_4:1.104 PTH_1_1_3:1.103 PTH_1_1_2:1.103 PTH_1_1_1:1.102 PTH_1_1_0:1.102 PTH_1_1b7:1.101 PTH_1_1b6:1.101 PTH_1_1b5:1.101 PTH_1_1b4:1.100 PTH_1_1b3:1.99 PTH_1_1b2:1.99 PTH_1_1b1:1.99 PTH_1_0_4:1.96 PTH_1_0_3:1.96 PTH_1_0_2:1.93 PTH_1_0_1:1.92 PTH_1_0_0:1.87 PTH_1_0b8:1.85 PTH_1_0b7:1.85 PTH_1_0b6:1.84 PTH_1_0b5:1.84 PTH_1_0b4:1.79 PTH_1_0b3:1.76 PTH_1_0b2:1.74 PTH_1_0b1:1.71 PTH_0_9_21:1.67 PTH_0_9_20:1.61 PTH_0_9_19:1.55 PTH_0_9_18:1.49 PTH_0_9_17:1.42 PTH_0_9_16:1.42 PTH_0_9_15:1.40 PTH_0_9_14:1.38 PTH_0_9_13:1.36 PTH_0_9_12:1.32 PTH_0_9_11:1.27 PTH_0_9_10:1.26 PTH_0_9_9:1.26 PTH_0_9_8:1.26 PTH_0_9_7:1.20 PTH_0_9_6:1.16 PTH_0_9_5:1.13 PTH_0_9_4:1.12 PTH_0_9_3:1.8 PTH_0_9_2:1.4 PTH_0_9_1:1.2 PTH_0_9_0:1.1.1.1 RSE:1.1.1; locks; strict; comment @# @; 1.147 date 2007.01.01.18.23.52; author rse; state Exp; branches; next 1.146; commitid 9DhdiirNzQPBIP0s; 1.146 date 2006.06.08.17.54.52; author rse; state Exp; branches; next 1.145; commitid x8N3mLVdQgkbdeAr; 1.145 date 2004.12.31.19.34.44; author rse; state Exp; branches; next 1.144; 1.144 date 2004.12.03.16.21.08; author rse; state Exp; branches; next 1.143; 1.143 date 2004.10.08.16.17.02; author rse; state Exp; branches; next 1.142; 1.142 date 2004.09.12.11.36.13; author rse; state Exp; branches; next 1.141; 1.141 date 2004.07.13.10.50.49; author rse; state Exp; branches; next 1.140; 1.140 date 2003.01.01.15.49.11; author rse; state Exp; branches; next 1.139; 1.139 date 2002.11.08.16.05.54; author rse; state Exp; branches; next 1.138; 1.138 date 2002.11.05.19.39.09; author rse; state Exp; branches; next 1.137; 1.137 date 2002.11.03.16.31.34; author rse; state Exp; branches; next 1.136; 1.136 date 2002.11.03.11.15.04; author rse; state Exp; branches; next 1.135; 1.135 date 2002.11.03.09.59.32; author rse; state Exp; branches; next 1.134; 1.134 date 2002.10.25.11.56.16; author rse; state Exp; branches; next 1.133; 1.133 date 2002.10.23.14.04.00; author rse; state Exp; branches; next 1.132; 1.132 date 2002.10.15.21.14.27; author rse; state Exp; branches; next 1.131; 1.131 date 2002.01.27.11.03.40; author rse; state Exp; branches; next 1.130; 1.130 date 2001.07.24.18.55.36; author rse; state Exp; branches; next 1.129; 1.129 date 2001.03.24.14.51.04; author rse; state Exp; branches; next 1.128; 1.128 date 2001.03.24.13.49.06; author rse; state Exp; branches; next 1.127; 1.127 date 2000.10.03.09.26.47; author rse; state Exp; branches; next 1.126; 1.126 date 2000.03.27.17.01.47; author rse; state Exp; branches; next 1.125; 1.125 date 2000.03.12.19.13.42; author rse; state Exp; branches; next 1.124; 1.124 date 2000.03.12.16.43.16; author rse; state Exp; branches; next 1.123; 1.123 date 2000.03.10.09.43.08; author rse; state Exp; branches 1.123.2.1; next 1.122; 1.122 date 2000.03.09.12.11.51; author rse; state Exp; branches; next 1.121; 1.121 date 2000.02.13.17.24.02; author rse; state Exp; branches; next 1.120; 1.120 date 2000.01.26.13.06.38; author rse; state Exp; branches; next 1.119; 1.119 date 2000.01.26.12.26.51; author rse; state Exp; branches; next 1.118; 1.118 date 2000.01.07.22.35.49; author rse; state Exp; branches; next 1.117; 1.117 date 99.12.30.21.58.59; author rse; state Exp; branches; next 1.116; 1.116 date 99.12.15.18.14.08; author rse; state Exp; branches; next 1.115; 1.115 date 99.11.09.08.11.31; author rse; state Exp; branches; next 1.114; 1.114 date 99.11.02.18.19.00; author rse; state Exp; branches; next 1.113; 1.113 date 99.11.02.14.15.07; author rse; state Exp; branches; next 1.112; 1.112 date 99.11.01.10.27.18; author rse; state Exp; branches; next 1.111; 1.111 date 99.10.31.11.46.12; author rse; state Exp; branches 1.111.2.1; next 1.110; 1.110 date 99.10.26.13.06.47; author rse; state Exp; branches; next 1.109; 1.109 date 99.10.19.14.40.25; author rse; state Exp; branches; next 1.108; 1.108 date 99.09.17.08.01.54; author rse; state Exp; branches; next 1.107; 1.107 date 99.09.01.08.51.23; author rse; state Exp; branches; next 1.106; 1.106 date 99.08.31.11.24.58; author rse; state Exp; branches; next 1.105; 1.105 date 99.08.31.07.56.31; author rse; state Exp; branches; next 1.104; 1.104 date 99.08.30.13.43.13; author rse; state Exp; branches 1.104.2.1; next 1.103; 1.103 date 99.08.23.12.00.53; author rse; state Exp; branches; next 1.102; 1.102 date 99.08.19.15.08.52; author rse; state Exp; branches; next 1.101; 1.101 date 99.08.17.08.08.35; author rse; state Exp; branches; next 1.100; 1.100 date 99.08.13.13.35.06; author rse; state Exp; branches; next 1.99; 1.99 date 99.08.03.12.56.35; author rse; state Exp; branches; next 1.98; 1.98 date 99.08.03.12.28.42; author rse; state Exp; branches; next 1.97; 1.97 date 99.08.03.12.24.02; author rse; state Exp; branches; next 1.96; 1.96 date 99.07.30.10.35.28; author rse; state Exp; branches; next 1.95; 1.95 date 99.07.30.07.13.59; author rse; state Exp; branches; next 1.94; 1.94 date 99.07.30.06.19.42; author rse; state Exp; branches; next 1.93; 1.93 date 99.07.24.13.25.17; author rse; state Exp; branches; next 1.92; 1.92 date 99.07.22.15.53.14; author rse; state Exp; branches; next 1.91; 1.91 date 99.07.22.14.55.09; author rse; state Exp; branches; next 1.90; 1.90 date 99.07.19.06.39.20; author rse; state Exp; branches; next 1.89; 1.89 date 99.07.19.06.36.48; author rse; state Exp; branches; next 1.88; 1.88 date 99.07.19.06.09.47; author rse; state Exp; branches; next 1.87; 1.87 date 99.07.16.11.40.11; author rse; state Exp; branches; next 1.86; 1.86 date 99.07.16.09.57.11; author rse; state Exp; branches; next 1.85; 1.85 date 99.07.14.18.53.14; author rse; state Exp; branches; next 1.84; 1.84 date 99.07.10.15.20.02; author rse; state Exp; branches; next 1.83; 1.83 date 99.07.10.15.14.47; author rse; state Exp; branches; next 1.82; 1.82 date 99.07.10.14.21.17; author rse; state Exp; branches; next 1.81; 1.81 date 99.07.09.08.06.41; author rse; state Exp; branches; next 1.80; 1.80 date 99.07.08.15.01.17; author rse; state Exp; branches; next 1.79; 1.79 date 99.07.08.10.34.00; author rse; state Exp; branches; next 1.78; 1.78 date 99.07.08.10.19.10; author rse; state Exp; branches; next 1.77; 1.77 date 99.07.08.09.41.00; author rse; state Exp; branches; next 1.76; 1.76 date 99.07.07.19.02.28; author rse; state Exp; branches; next 1.75; 1.75 date 99.07.07.12.42.02; author rse; state Exp; branches; next 1.74; 1.74 date 99.07.04.12.05.35; author rse; state Exp; branches; next 1.73; 1.73 date 99.07.03.12.47.38; author rse; state Exp; branches; next 1.72; 1.72 date 99.06.28.17.15.56; author rse; state Exp; branches; next 1.71; 1.71 date 99.06.28.11.36.26; author rse; state Exp; branches; next 1.70; 1.70 date 99.06.28.07.51.55; author rse; state Exp; branches; next 1.69; 1.69 date 99.06.27.15.40.30; author rse; state Exp; branches; next 1.68; 1.68 date 99.06.27.15.38.04; author rse; state Exp; branches; next 1.67; 1.67 date 99.06.26.12.59.56; author rse; state Exp; branches; next 1.66; 1.66 date 99.06.26.12.58.14; author rse; state Exp; branches; next 1.65; 1.65 date 99.06.26.12.54.17; author rse; state Exp; branches; next 1.64; 1.64 date 99.06.26.12.51.27; author rse; state Exp; branches; next 1.63; 1.63 date 99.06.26.12.47.55; author rse; state Exp; branches; next 1.62; 1.62 date 99.06.26.12.30.55; author rse; state Exp; branches; next 1.61; 1.61 date 99.06.25.15.28.13; author rse; state Exp; branches; next 1.60; 1.60 date 99.06.24.12.24.46; author rse; state Exp; branches; next 1.59; 1.59 date 99.06.24.12.07.31; author rse; state Exp; branches; next 1.58; 1.58 date 99.06.24.11.50.04; author rse; state Exp; branches; next 1.57; 1.57 date 99.06.24.11.25.07; author rse; state Exp; branches; next 1.56; 1.56 date 99.06.24.10.54.29; author rse; state Exp; branches; next 1.55; 1.55 date 99.06.21.15.24.04; author rse; state Exp; branches; next 1.54; 1.54 date 99.06.21.14.24.47; author rse; state Exp; branches; next 1.53; 1.53 date 99.06.21.10.31.29; author rse; state Exp; branches; next 1.52; 1.52 date 99.06.21.10.07.29; author rse; state Exp; branches; next 1.51; 1.51 date 99.06.21.09.42.57; author rse; state Exp; branches; next 1.50; 1.50 date 99.06.21.08.32.07; author rse; state Exp; branches; next 1.49; 1.49 date 99.06.20.09.52.02; author rse; state Exp; branches; next 1.48; 1.48 date 99.06.20.09.44.27; author rse; state Exp; branches; next 1.47; 1.47 date 99.06.19.15.59.54; author rse; state Exp; branches; next 1.46; 1.46 date 99.06.19.15.44.16; author rse; state Exp; branches; next 1.45; 1.45 date 99.06.19.15.11.35; author rse; state Exp; branches; next 1.44; 1.44 date 99.06.19.13.00.13; author rse; state Exp; branches; next 1.43; 1.43 date 99.06.19.11.58.06; author rse; state Exp; branches; next 1.42; 1.42 date 99.06.09.06.51.19; author rse; state Exp; branches; next 1.41; 1.41 date 99.06.04.21.26.10; author rse; state Exp; branches; next 1.40; 1.40 date 99.06.04.10.47.42; author rse; state Exp; branches; next 1.39; 1.39 date 99.06.03.09.30.51; author rse; state Exp; branches; next 1.38; 1.38 date 99.06.01.15.29.22; author rse; state Exp; branches; next 1.37; 1.37 date 99.06.01.14.36.33; author rse; state Exp; branches; next 1.36; 1.36 date 99.06.01.10.05.29; author rse; state Exp; branches; next 1.35; 1.35 date 99.06.01.09.55.26; author rse; state Exp; branches; next 1.34; 1.34 date 99.06.01.08.33.05; author rse; state Exp; branches; next 1.33; 1.33 date 99.05.31.12.43.00; author rse; state Exp; branches; next 1.32; 1.32 date 99.05.30.13.08.37; author rse; state Exp; branches; next 1.31; 1.31 date 99.05.30.10.06.32; author rse; state Exp; branches; next 1.30; 1.30 date 99.05.30.09.51.00; author rse; state Exp; branches; next 1.29; 1.29 date 99.05.30.09.28.24; author rse; state Exp; branches; next 1.28; 1.28 date 99.05.29.11.10.01; author rse; state Exp; branches; next 1.27; 1.27 date 99.05.28.16.23.14; author rse; state Exp; branches; next 1.26; 1.26 date 99.05.24.10.54.27; author rse; state Exp; branches; next 1.25; 1.25 date 99.05.24.10.24.24; author rse; state Exp; branches; next 1.24; 1.24 date 99.05.24.10.07.44; author rse; state Exp; branches; next 1.23; 1.23 date 99.05.24.07.58.13; author rse; state Exp; branches; next 1.22; 1.22 date 99.05.24.07.45.56; author rse; state Exp; branches; next 1.21; 1.21 date 99.05.24.07.28.00; author rse; state Exp; branches; next 1.20; 1.20 date 99.05.23.14.11.53; author rse; state Exp; branches; next 1.19; 1.19 date 99.05.23.14.09.36; author rse; state Exp; branches; next 1.18; 1.18 date 99.05.23.14.08.41; author rse; state Exp; branches; next 1.17; 1.17 date 99.05.23.12.37.55; author rse; state Exp; branches; next 1.16; 1.16 date 99.05.22.14.37.52; author rse; state Exp; branches; next 1.15; 1.15 date 99.05.21.16.36.26; author rse; state Exp; branches; next 1.14; 1.14 date 99.05.21.16.00.14; author rse; state Exp; branches; next 1.13; 1.13 date 99.05.21.15.22.32; author rse; state Exp; branches; next 1.12; 1.12 date 99.05.21.13.43.06; author rse; state Exp; branches; next 1.11; 1.11 date 99.05.21.13.39.18; author rse; state Exp; branches; next 1.10; 1.10 date 99.05.21.09.44.10; author rse; state Exp; branches; next 1.9; 1.9 date 99.05.15.15.29.43; author rse; state Exp; branches; next 1.8; 1.8 date 99.05.14.19.44.07; author rse; state Exp; branches; next 1.7; 1.7 date 99.05.14.19.33.37; author rse; state Exp; branches; next 1.6; 1.6 date 99.05.14.16.29.08; author rse; state Exp; branches; next 1.5; 1.5 date 99.05.14.16.11.48; author rse; state Exp; branches; next 1.4; 1.4 date 99.05.14.10.06.02; author rse; state Exp; branches; next 1.3; 1.3 date 99.05.14.09.40.05; author rse; state Exp; branches; next 1.2; 1.2 date 99.05.13.12.25.42; author rse; state Exp; branches; next 1.1; 1.1 date 99.05.13.12.18.16; author rse; state Exp; branches 1.1.1.1; next ; 1.123.2.1 date 2000.03.27.17.04.17; author rse; state Exp; branches; next ; 1.111.2.1 date 99.11.01.10.24.58; author rse; state Exp; branches; next 1.111.2.2; 1.111.2.2 date 2000.01.07.23.16.17; author rse; state Exp; branches; next ; 1.104.2.1 date 99.08.31.11.25.34; author rse; state Exp; branches; next ; 1.1.1.1 date 99.05.13.12.18.16; author rse; state Exp; branches; next ; desc @@ 1.147 log @Adjusted all copyright messages for new year 2007. @ text @/* ** GNU Pth - The GNU Portable Threads ** Copyright (c) 1999-2007 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 timespec */ #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; struct timespec; /* 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 /* check if the user requests a bigger FD_SETSIZE than we can handle */ #if defined(FD_SETSIZE) #if FD_SETSIZE > @@PTH_FDSETSIZE@@ #error "FD_SETSIZE is larger than what GNU Pth can handle." #endif #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) #define PTH_CTRL_FAVOURNEW _BIT(11) /* 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_DISPATCHES, /* RO [int] total number of thread dispatches */ 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) /* event status codes */ typedef enum { PTH_STATUS_PENDING, PTH_STATUS_OCCURRED, PTH_STATUS_FAILED } pth_status_t; /* 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, 0 } /* barrier variable values */ #define PTH_BARRIER_INITIALIZED _BIT(0) #define PTH_BARRIER_INIT(threshold) { PTH_BARRIER_INITIALIZED, \ (threshold), (threshold), FALSE, \ PTH_COND_INIT, PTH_MUTEX_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; }; /* the user-space context structure */ typedef struct pth_uctx_st *pth_uctx_t; struct pth_uctx_st; /* 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 */ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE #define _XOPEN_SOURCE_set #endif #include #ifdef _XOPEN_SOURCE_set #undef _XOPEN_SOURCE_set #undef _XOPEN_SOURCE #endif #ifndef POLLRDNORM #define POLLRDNORM POLLIN #endif #ifndef POLLRDBAND #define POLLRDBAND POLLIN #endif #ifndef POLLWRNORM #define POLLWRNORM POLLOUT #endif #ifndef POLLWRBAND #define POLLWRBAND POLLOUT #endif #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 pth_status_t pth_event_status(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 *); /* user-space context functions */ extern int pth_uctx_create(pth_uctx_t *); extern int pth_uctx_make(pth_uctx_t, char *, size_t, const sigset_t *, void (*)(void *), void *, pth_uctx_t); extern int pth_uctx_switch(pth_uctx_t, pth_uctx_t); extern int pth_uctx_destroy(pth_uctx_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_nanosleep(const struct timespec *, struct timespec *); 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_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); extern int pth_poll(struct pollfd *, nfds_t, int); extern ssize_t pth_read(int, void *, size_t); extern ssize_t pth_write(int, const void *, size_t); 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 nanosleep pth_nanosleep #define usleep pth_usleep #define sleep pth_sleep #define sigprocmask pth_sigmask #define sigwait pth_sigwait #define select pth_select #define pselect pth_pselect #define poll pth_poll #define connect pth_connect #define accept pth_accept #define read pth_read #define write pth_write #define readv pth_readv #define writev pth_writev #define recv pth_recv #define send pth_send #define recvfrom pth_recvfrom #define sendto pth_sendto #define pread pth_pread #define pwrite pth_pwrite #endif /* backward compatibility (Pth < 1.5.0) */ #define pth_event_occurred(ev) \ ( pth_event_status(ev) == PTH_STATUS_OCCURRED \ || pth_event_status(ev) == PTH_STATUS_FAILED ) #endif /* _PTH_H_ */ @ 1.146 log @Adjusted all copyright messages for new year 2006 @ text @d3 1 a3 1 ** Copyright (c) 1999-2006 Ralf S. Engelschall @ 1.145 log @Adjusted all copyright messages for new year 2005. @ text @d3 1 a3 1 ** Copyright (c) 1999-2005 Ralf S. Engelschall @ 1.144 log @The pth_uctx_save() and pth_uctx_restore() API functions unfortunately were broken by design because they are C _functions_. This leads to one more deadly nesting on the run-time stack which effectively caused the pth_mctx_restore() in pth_uctx_restore() to return to the end of pth_uctx_save() but then the control flow unfortunately returns to the pth_uctx_restore() caller instead of the pth_uctx_save() caller because the call to pth_uctx_restore() had already overwritten the run-time stack position where the original return address for the pth_uctx_save() call was stored. The only workaround would be to #define pth_uctx_save() and pth_uctx_restore() as C _macros_, but this then would require that lots of the GNU Pth internals from pth_mctx.c would have to be exported in the GNU Pth API (which in turn is not acceptable). So, the only consequence is to remove the two functions again from the GNU Pth API. Prompted by hints from: Stefan Brantschen @ text @d3 1 a3 1 ** Copyright (c) 1999-2004 Ralf S. Engelschall @ 1.143 log @Added PTH_CTRL_FAVOURNEW control which allows the user to disable the favouring of new threads on scheduling to get more strict priority based scheduling behavior. Triggered by: Vinu V @ text @a507 2 extern int pth_uctx_save(pth_uctx_t); extern int pth_uctx_restore(pth_uctx_t); @ 1.142 log @Avoid side-effects by defining _XOPEN_SOURCE only temporarily for inclusion of instead of permanently. Submitted by: Graham Nash @ text @d127 1 @ 1.141 log @Adjusted all copyright messages for new year 2004. @ text @d341 1 d343 2 d346 4 @ 1.140 log @Adjusted all copyright messages for new year 2003. @ text @d3 1 a3 1 ** Copyright (c) 1999-2003 Ralf S. Engelschall @ 1.139 log @Added soft and hard syscall mapping for nanosleep(3) and usleep(3) functions. @ text @d3 1 a3 1 ** Copyright (c) 1999-2002 Ralf S. Engelschall @ 1.138 log @1. The function "int pth_event_occurred(pth_event_t)" was replaced with "pth_status_t pth_event_status(pth_event_t)" where pth_status_t can have values of PTH_STATUS_PENDING (replacing the old FALSE return value of pth_event_occurred), PTH_STATUS_OCCURRED (replacing the old TRUE return value of pth_event_occurred), and PTH_STATUS_FAILED (a new return value indicating an error in processing the event). This was scheduler/event-manager errors can be indicated which happended while processing the event. For backward compatibility reasons, a macro pth_event_occurred() was added. This will be removed soon. 2. Use the new PTH_STATUS_FAILED event status in the scheduler's event-manager for filedescriptor events if the internal select(2) call returned with an error. Additionally this PTH_STATUS_FAILED is recognized by the high-level API functions (pth_select, etc) and produce the necessary POSIX conforming return codes (usually -1 and errno == EBADF). Parts submitted by: Thanh Luu @ text @d554 2 @ 1.137 log @Add Autoconf option --with-fdsetsize=NUM which allows to force a particular (usually higher than the default) FD_SETSIZE value for building Pth. Additionally Pth makes sure that the application using Pth does not use an even larger size. Original patch by: Nick Hudson @ text @d212 7 d457 1 a457 1 extern int pth_event_occurred(pth_event_t); d573 5 @ 1.136 log @Added thread attribute PTH_ATTR_DISPATCHES which (in bounded attribute objects) is incremented every time the context is switched to the associated thread. This can be used for statistical information. @ text @d90 7 @ 1.135 log @Added a stand-alone sub-API for manual user-space context switching. It is somewhat modeled after the POSIX ucontext(3) facility and consists of an opaque data type pth_uctx_t and the management functions pth_uctx_create(), pth_uctx_make(), pth_uctx_save(), pth_uctx_restore(), pth_uctx_switch() and pth_uctx_destroy(). These functions are based on the same underlying machine context switching facility (pth_mctx) the threads in GNU Pth are using. This facility can be used to implement co-routines without a full real multithreading environment or even to implement an own multithreading environment. @ text @d154 1 @ 1.134 log @Add a Pth variant of the new POSIX pselect(2) function, including soft and hard syscall mapping support for it. @ text @d309 4 d481 8 @ 1.133 log @Added pth_nanosleep() function. Obtained from: NetBSD, Nick Hudson @ text @d507 1 d531 1 @ 1.132 log @Added support to pth_poll(3) for the poll(2) XPG.4 flags POLLD{RD,WR}{NORM,BAND}. Submitted by: Jason Evans Final shaping by: Ralf S. Engelschall @ text @d42 5 a46 4 #include /* for ssize_t, off_t */ #include /* for struct timeval */ #include /* for sockaddr */ #include /* for sigset_t */ d62 1 d497 1 @ 1.131 log @bump copyright year @ text @d320 1 d322 12 @ 1.130 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2001 Ralf S. Engelschall @ 1.129 log @*** empty log message *** @ text @d247 1 a247 1 #define PTH_COND_INIT { PTH_COND_INITIALIZED } d251 3 a253 2 #define PTH_BARRIER_INIT(threshold) { PTH_BARRIER_INITIALIZED, (threshold), 0, 0, \ PTH_MUTEX_INIT, PTH_COND_INIT } @ 1.128 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2000 Ralf S. Engelschall @ 1.127 log @*** empty log message *** @ text @d520 4 @ 1.126 log @*** empty log message *** @ text @d484 1 d507 2 a511 1 #define waitpid pth_waitpid @ 1.125 log @*** empty log message *** @ text @d46 1 @ 1.124 log @*** empty log message *** @ text @d474 4 d493 4 @ 1.123 log @*** empty log message *** @ text @d217 2 a218 1 pth_ringnode_t *rn_hook; @ 1.123.2.1 log @*** empty log message *** @ text @a45 1 @@EXTRA_INCLUDE_SYS_SELECT_H@@ @ 1.122 log @*** empty log message *** @ text @d290 1 @ 1.121 log @*** empty log message *** @ text @d405 2 a406 2 extern pth_time_t pth_time(int, int); extern pth_time_t pth_timeout(int, int); @ 1.120 log @*** empty log message *** @ text @d177 1 a177 2 #define PTH_EVENT_PID _BIT(9) #define PTH_EVENT_FUNC _BIT(10) @ 1.119 log @*** empty log message *** @ text @d108 2 a109 1 #define PTH_CTRL_GETTHREADS_DEAD _BIT(8) d114 1 d116 1 a116 1 #define PTH_CTRL_DUMPSTATE _BIT(9) d393 2 @ 1.118 log @*** empty log message *** @ text @d101 14 a114 14 #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_DEAD _BIT(8) #define PTH_CTRL_GETTHREADS (PTH_CTRL_GETTHREADS_NEW|\ PTH_CTRL_GETTHREADS_READY|\ PTH_CTRL_GETTHREADS_RUNNING|\ PTH_CTRL_GETTHREADS_WAITING|\ PTH_CTRL_GETTHREADS_DEAD) #define PTH_CTRL_DUMPSTATE _BIT(9) @ 1.117 log @*** empty log message *** @ text @d114 1 @ 1.116 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999 Ralf S. Engelschall @ 1.115 log @*** empty log message *** @ text @d374 1 a374 1 extern void pth_kill(void); @ 1.114 log @*** empty log message *** @ text @d60 1 a60 1 d409 1 a409 1 extern pth_event_t pth_event(unsigned long, ...); @ 1.113 log @*** empty log message *** @ text @d32 1 a32 1 #define PTH_VERSION_STR @@PTH_VERSION_STR@@ @ 1.112 log @*** empty log message *** @ text @d31 6 d38 1 a38 1 #define PTH_VERSION @@PTH_VERSION_HEX@@ @ 1.111 log @*** empty log message *** @ text @d2 1 a2 2 ** pth.h -- Pth public API definitions ** d22 2 @ 1.111.2.1 log @*** empty log message *** @ text @d2 2 a3 1 ** GNU Pth - The GNU Portable Threads a22 2 ** ** pth.h: Pth public API definitions @ 1.111.2.2 log @*** empty log message *** @ text @d368 1 a368 1 extern int pth_kill(void); @ 1.110 log @*** empty log message *** @ text @d12 1 a12 1 ** version 2 of the License, or (at your option) any later version. @ 1.109 log @*** empty log message *** @ text @d41 1 a41 1 #ifndef _PTH_PTHREAD_H_ /* pthread.h contains same fallbacks */ d49 1 a49 1 #endif d303 1 d332 1 d335 1 d353 1 @ 1.108 log @*** empty log message *** @ text @d48 1 d452 1 a452 1 extern int pth_poll_ev(struct pollfd *, unsigned int, int, pth_event_t); d467 1 a467 1 extern int pth_poll(struct pollfd *, unsigned int, int); @ 1.107 log @*** empty log message *** @ text @d10 1 a10 1 ** modify it under the terms of the GNU Library General Public d17 1 a17 1 ** Library General Public License for more details. d19 1 a19 1 ** You should have received a copy of the GNU Library General Public @ 1.106 log @*** empty log message *** @ text @d478 15 a492 14 #define fork pth_fork #define sleep pth_sleep #define sigwait pth_sigwait #define waitpid pth_waitpid #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 @ 1.105 log @*** empty log message *** @ text @d45 1 d448 2 a449 2 extern int pth_connect_ev(int, const struct sockaddr *, int, pth_event_t); extern int pth_accept_ev(int, struct sockaddr *, int *, pth_event_t); d463 2 a464 2 extern int pth_connect(int, const struct sockaddr *, int); extern int pth_accept(int, struct sockaddr *, int *); @ 1.104 log @*** empty log message *** @ text @d41 1 d47 1 @ 1.104.2.1 log @*** empty log message *** @ text @a40 1 #ifndef _PTH_PTHREAD_H_ /* pthread.h contains same fallbacks */ a45 1 #endif @ 1.103 log @*** empty log message *** @ text @d37 2 a38 2 #include /* for sockaddr */ #include /* for sigset_t */ d113 3 a115 3 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 */ d117 1 a117 1 PTH_STATE_DEAD /* terminated, waiting to be joined */ d131 14 a144 14 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 */ d308 4 a311 4 #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 */ d313 1 a313 1 #define POLLNVAL 0x0020 /* requested events "invalid" */ d323 2 a324 2 short events; /* events we are interested in */ short revents; /* events found on return */ @ 1.102 log @*** empty log message *** @ text @d375 1 a375 1 extern void pth_yield(pth_t); @ 1.101 log @*** empty log message *** @ text @d24 2 a25 1 @ 1.100 log @*** empty log message *** @ text @d357 4 a360 4 int pth_init(void); void pth_kill(void); long pth_ctrl(unsigned long, ...); long pth_version(void); d363 6 a368 6 pth_attr_t pth_attr_of(pth_t); pth_attr_t pth_attr_new(void); int pth_attr_init(pth_attr_t); int pth_attr_set(pth_attr_t, int, ...); int pth_attr_get(pth_attr_t, int, ...); int pth_attr_destroy(pth_attr_t); d371 11 a381 11 pth_t pth_spawn(pth_attr_t, void *(*)(void *), void *); int pth_once(pth_once_t *, void (*)(void *), void *); pth_t pth_self(void); void pth_yield(pth_t); int pth_nap(pth_time_t); int pth_wait(pth_event_t); int pth_cancel(pth_t); int pth_abort(pth_t); int pth_raise(pth_t, int); int pth_join(pth_t, void **); void pth_exit(void *); d384 3 a386 3 int pth_fdmode(int, int); pth_time_t pth_time(int, int); pth_time_t pth_timeout(int, int); d389 2 a390 2 void pth_cancel_state(int, int *); void pth_cancel_point(void); d393 8 a400 8 pth_event_t pth_event(unsigned long, ...); unsigned long pth_event_typeof(pth_event_t); int pth_event_extract(pth_event_t ev, ...); pth_event_t pth_event_concat(pth_event_t, ...); pth_event_t pth_event_isolate(pth_event_t); pth_event_t pth_event_walk(pth_event_t, unsigned int); int pth_event_occurred(pth_event_t); int pth_event_free(pth_event_t, int); d403 4 a406 4 int pth_key_create(pth_key_t *, void (*)(void *)); int pth_key_delete(pth_key_t); int pth_key_setdata(pth_key_t, const void *); void *pth_key_getdata(pth_key_t); d409 7 a415 7 pth_msgport_t pth_msgport_create(const char *); void pth_msgport_destroy(pth_msgport_t); pth_msgport_t pth_msgport_find(const char *); int pth_msgport_pending(pth_msgport_t); int pth_msgport_put(pth_msgport_t, pth_message_t *); pth_message_t *pth_msgport_get(pth_msgport_t); int pth_msgport_reply(pth_message_t *); d418 2 a419 2 int pth_cleanup_push(void (*)(void *), void *); int pth_cleanup_pop(int); d422 3 a424 3 int pth_atfork_push(void (*)(void *), void (*)(void *), void (*)(void *), void *); int pth_atfork_pop(void); pid_t pth_fork(void); d427 11 a437 11 int pth_mutex_init(pth_mutex_t *); int pth_mutex_acquire(pth_mutex_t *, int, pth_event_t); int pth_mutex_release(pth_mutex_t *); int pth_rwlock_init(pth_rwlock_t *); int pth_rwlock_acquire(pth_rwlock_t *, int, int, pth_event_t); int pth_rwlock_release(pth_rwlock_t *); int pth_cond_init(pth_cond_t *); int pth_cond_await(pth_cond_t *, pth_mutex_t *, pth_event_t); int pth_cond_notify(pth_cond_t *, int); int pth_barrier_init(pth_barrier_t *, int); int pth_barrier_reach(pth_barrier_t *); d440 1 a440 1 Sfdisc_t *pth_sfiodisc(void); d443 9 a451 9 int pth_sigwait_ev(const sigset_t *, int *, pth_event_t); int pth_connect_ev(int, const struct sockaddr *, int, pth_event_t); int pth_accept_ev(int, struct sockaddr *, int *, pth_event_t); int pth_select_ev(int, fd_set *, fd_set *, fd_set *, struct timeval *, pth_event_t); int pth_poll_ev(struct pollfd *, unsigned int, int, pth_event_t); ssize_t pth_read_ev(int, void *, size_t, pth_event_t); ssize_t pth_write_ev(int, const void *, size_t, pth_event_t); ssize_t pth_readv_ev(int, const struct iovec *, int, pth_event_t); ssize_t pth_writev_ev(int, const struct iovec *, int, pth_event_t); d454 15 a468 15 int pth_usleep(unsigned int); unsigned int pth_sleep(unsigned int); pid_t pth_waitpid(pid_t, int *, int); int pth_sigmask(int, const sigset_t *, sigset_t *); int pth_sigwait(const sigset_t *, int *); int pth_connect(int, const struct sockaddr *, int); int pth_accept(int, struct sockaddr *, int *); int pth_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); int pth_poll(struct pollfd *, unsigned int, int); ssize_t pth_read(int, void *, size_t); ssize_t pth_write(int, const void *, size_t); ssize_t pth_readv(int, const struct iovec *, int); ssize_t pth_writev(int, const struct iovec *, int); ssize_t pth_pread(int, void *, size_t, off_t); ssize_t pth_pwrite(int, const void *, size_t, off_t); @ 1.99 log @*** empty log message *** @ text @d332 3 d341 3 @ 1.98 log @*** empty log message *** @ text @d340 10 d432 3 @ 1.97 log @*** empty log message *** @ text @d233 7 d278 11 d420 2 @ 1.96 log @*** empty log message *** @ text @d271 8 d350 1 a350 1 int pth_nonblocking(int); @ 1.95 log @*** empty log message *** @ text @d112 5 a116 5 PTH_STATE_SCHEDULER = 0, PTH_STATE_NEW, PTH_STATE_READY, PTH_STATE_WAITING, PTH_STATE_DEAD d146 1 a146 1 /* default thread attributes */ @ 1.94 log @*** empty log message *** @ text @d146 2 a147 2 /* null attribute */ #define PTH_ATTR_NULL (pth_attr_t)(0) @ 1.93 log @*** empty log message *** @ text @d35 1 a35 1 #include /* for struct timeval/timespec */ a47 1 struct timespec; @ 1.92 log @*** empty log message *** @ text @d25 2 a26 2 #ifndef _PTH_H #define _PTH_H d444 1 a444 1 #endif /* _PTH_H */ @ 1.91 log @*** empty log message *** @ text @d34 1 a34 1 #include /* for ssize_t */ a37 1 #include /* for off_t */ @ 1.90 log @*** empty log message *** @ text @d38 1 a38 4 /* extra structure definitions */ struct timeval; struct timespec; a40 1 @@FALLBACK_SIG_ATOMIC_T@@ d44 6 d274 2 a275 1 #if !(@@PTH_FAKE_POLL@@) d303 13 d405 2 d420 4 d439 4 @ 1.89 log @*** empty log message *** @ text @d400 1 a400 1 ssize_t pth_read(int fd, void *, size_t); @ 1.88 log @*** empty log message *** @ text @a387 1 ssize_t pth_readline_ev(int, void *, size_t, pth_event_t); a400 1 ssize_t pth_readline(int, void *, size_t); @ 1.87 log @*** empty log message *** @ text @d35 1 a35 1 #include /* for struct timeval */ d38 4 @ 1.86 log @*** empty log message *** @ text @a405 1 /* #define usleep pth_usleep !! too unstandardized !! */ @ 1.85 log @*** empty log message *** @ text @d404 1 a404 1 #if PTH_SYSCALL_SOFT d406 1 a406 3 #if 0 /* too unstandardized */ #define usleep pth_usleep #endif @ 1.84 log @*** empty log message *** @ text @d406 1 d408 1 @ 1.83 log @*** empty log message *** @ text @d268 8 a275 1 #if @@PTH_FAKE_POLL@@ a293 2 #else struct pollfd; @ 1.82 log @*** empty log message *** @ text @d267 24 d377 1 d391 1 d406 1 @ 1.81 log @*** empty log message *** @ text @d78 6 d350 1 a350 1 int pth_connect_ev(int, struct sockaddr *, int, pth_event_t); d363 1 a363 1 int pth_connect(int, struct sockaddr *, int); d371 14 @ 1.80 log @*** empty log message *** @ text @d145 9 a153 8 #define PTH_EVENT_SIGS _BIT(2) #define PTH_EVENT_TIME _BIT(3) #define PTH_EVENT_MSG _BIT(4) #define PTH_EVENT_MUTEX _BIT(5) #define PTH_EVENT_COND _BIT(6) #define PTH_EVENT_TID _BIT(7) #define PTH_EVENT_PID _BIT(8) #define PTH_EVENT_FUNC _BIT(9) d156 8 a163 8 #define PTH_UNTIL_OCCURRED _BIT(10) #define PTH_UNTIL_FD_READABLE _BIT(11) #define PTH_UNTIL_FD_WRITEABLE _BIT(12) #define PTH_UNTIL_FD_EXCEPTION _BIT(13) #define PTH_UNTIL_TID_NEW _BIT(14) #define PTH_UNTIL_TID_READY _BIT(15) #define PTH_UNTIL_TID_WAITING _BIT(16) #define PTH_UNTIL_TID_DEAD _BIT(17) d346 1 a346 1 ssize_t pth_write_ev(int, const void *, size_t, pth_event_t); d349 1 d359 1 a359 1 ssize_t pth_write(int, const void *, size_t); d362 1 @ 1.79 log @*** empty log message *** @ text @d282 1 @ 1.78 log @*** empty log message *** @ text @d2 1 a2 1 ** pth.h -- PTH public API definitions @ 1.77 log @*** empty log message *** @ text @d6 2 a7 2 ** This file is part of PTH, a non-preemptive thread scheduling library ** which can be found at http://www.gnu.org/software/pth/. @ 1.76 log @*** empty log message *** @ text @d75 1 d324 5 a348 1 pid_t pth_fork(void); @ 1.75 log @*** empty log message *** @ text @d296 2 @ 1.74 log @*** empty log message *** @ text @d172 2 a173 1 enum { PTH_WALK_NEXT, PTH_WALK_PREV }; @ 1.73 log @*** empty log message *** @ text @d7 1 a7 1 ** which can be found at http://www.engelschall.com/sw/pth/. @ 1.72 log @*** empty log message *** @ text @d179 2 a180 5 typedef struct pth_once_st pth_once_t; struct pth_once_st { int on_todo; }; #define PTH_ONCE_INIT { TRUE } @ 1.71 log @*** empty log message *** @ text @d265 1 a265 1 int pth_version(void); @ 1.70 log @*** empty log message *** @ text @d265 1 @ 1.69 log @*** empty log message *** @ text @d282 1 a285 4 /* signal handling */ int pth_sigmask(int, const sigset_t *, sigset_t *); int pth_sigraise(pth_t, int); d346 1 @ 1.68 log @*** empty log message *** @ text @d101 5 a105 5 pth_state_scheduler = 0, pth_state_new, pth_state_ready, pth_state_waiting, pth_state_dead @ 1.67 log @*** empty log message *** @ text @d59 3 d71 3 a73 2 /* some global constands */ #define PTH_KEY_INIT -1 a76 9 /* attribute values */ #define PTH_ATTR_NULL (pth_attr_t *)(0) #define PTH_ATTR_INIT { PTH_PRIO_STD, "unknown", PTH_FLAG_NONE, \ PTH_CANCEL_DEFAULT, 32*1024, NULL } /* values for the pth_attr() flags */ #define PTH_FLAG_NONE 0 #define PTH_FLAG_NOJOIN 1<<1 d78 8 a85 8 #define PTH_CTRL_GETAVLOAD 1<<1 #define PTH_CTRL_GETPRIO 1<<2 #define PTH_CTRL_GETNAME 1<<3 #define PTH_CTRL_GETTHREADS_NEW 1<<4 #define PTH_CTRL_GETTHREADS_READY 1<<5 #define PTH_CTRL_GETTHREADS_RUNNING 1<<6 #define PTH_CTRL_GETTHREADS_WAITING 1<<7 #define PTH_CTRL_GETTHREADS_DEAD 1<<8 d92 16 d113 29 d143 9 a151 9 #define PTH_EVENT_FD 1<<1 #define PTH_EVENT_SIGS 1<<2 #define PTH_EVENT_TIME 1<<3 #define PTH_EVENT_MSG 1<<4 #define PTH_EVENT_MUTEX 1<<5 #define PTH_EVENT_COND 1<<6 #define PTH_EVENT_TID 1<<7 #define PTH_EVENT_PID 1<<8 #define PTH_EVENT_FUNC 1<<9 d154 8 a161 8 #define PTH_UNTIL_OCCURRED 1<<10 #define PTH_UNTIL_FD_READABLE 1<<11 #define PTH_UNTIL_FD_WRITEABLE 1<<12 #define PTH_UNTIL_FD_EXCEPTION 1<<13 #define PTH_UNTIL_TID_NEW 1<<14 #define PTH_UNTIL_TID_READY 1<<15 #define PTH_UNTIL_TID_WAITING 1<<16 #define PTH_UNTIL_TID_DEAD 1<<17 d164 3 a166 3 #define PTH_MODE_REUSE 1<<20 #define PTH_MODE_CHAIN 1<<21 #define PTH_MODE_STATIC 1<<22 d169 1 a169 2 #define PTH_FREE_THIS 1 #define PTH_FREE_ALL 2 d172 5 a176 2 #define PTH_WALK_NEXT 1<<1 #define PTH_WALK_PREV 1<<2 d178 6 a183 4 /* once control init value */ #define PTH_ONCE_INIT_TODO 0 #define PTH_ONCE_INIT_DONE 1 #define PTH_ONCE_INIT { PTH_ONCE_INIT_TODO } d185 11 a195 2 /* ring init value */ #define PTH_RING_INIT { NULL } d198 4 a201 4 #define PTH_CANCEL_ENABLE 1<<0 #define PTH_CANCEL_DISABLE 1<<1 #define PTH_CANCEL_ASYNCHRONOUS 1<<2 #define PTH_CANCEL_DEFERRED 1<<3 d206 3 a208 5 #define PTH_MUTEX_INITIALIZED 1<<0 #ifdef _PTH_PRIVATE #define PTH_MUTEX_LOCKED 1<<1 #endif #define PTH_MUTEX_INIT { {NULL,NULL}, PTH_MUTEX_INITIALIZED, NULL, 0 } d211 2 a212 3 #define PTH_RWLOCK_RD 1 #define PTH_RWLOCK_RW 2 #define PTH_RWLOCK_INITIALIZED 1<<0 d217 4 a220 6 #define PTH_COND_INITIALIZED 1<<0 #ifdef _PTH_PRIVATE #define PTH_COND_SIGNALED 1<<1 #define PTH_COND_BROADCAST 1<<2 #define PTH_COND_HANDLED 1<<3 #endif a222 41 BEGIN_DECLARATION /* the unique thread id/handle */ #ifndef _PTH_PRIVATE typedef void *pth_t; #else typedef struct pth_st *pth_t; #endif /* the thread attribute structure */ typedef struct pth_attr_st pth_attr_t; struct pth_attr_st { int at_prio; char *at_name; unsigned int at_flags; unsigned int at_cancelstate; unsigned int at_stacksize; void *at_stackaddr; }; /* the key type */ typedef int pth_key_t; /* the event structure */ #ifndef _PTH_PRIVATE typedef void *pth_event_t; #else typedef struct pth_event_st *pth_event_t; #endif /* 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 *rn_hook; }; a223 3 #ifndef _PTH_PRIVATE typedef void *pth_msgport_t; /* opaque for application */ #else d225 1 a225 1 #endif d229 1 a229 1 struct pth_message_st { a235 6 /* the once structure */ typedef struct pth_once_st pth_once_t; struct pth_once_st { unsigned int on_state; }; d238 1 a238 1 struct pth_mutex_st { d240 1 a240 1 unsigned int mx_state; d247 2 a248 2 struct pth_rwlock_st { unsigned int rw_state; d257 1 a257 1 struct pth_cond_st { a260 3 /* the time value structure */ typedef struct timeval pth_time_t; d266 8 d275 1 a275 2 pth_attr_t pth_attr(char *, int, unsigned int, unsigned int, unsigned int, void *); pth_t pth_spawn(pth_attr_t *, void *(*)(void *), void *); a277 3 int pth_priority(pth_t, int); int pth_sigmask(int, const sigset_t *, sigset_t *); int pth_sigraise(pth_t, int); a281 1 int pth_detach(pth_t); d284 4 @ 1.66 log @*** empty log message *** @ text @d235 1 a235 1 unsigned int state; d334 1 a334 1 /* generalized variants of the replacement functions */ @ 1.65 log @*** empty log message *** @ text @d73 1 a73 1 /* the default value when a pth_attr_t is used */ d75 2 a275 1 int pth_equal(pth_t, pth_t); @ 1.64 log @*** empty log message *** @ text @d185 6 a190 6 int prio; char *name; unsigned int flags; unsigned int cancelstate; unsigned int stacksize; void *stackaddr; @ 1.63 log @*** empty log message *** @ text @d70 1 a70 1 #define PTH_KEYS_MAX 256 d155 1 a155 1 #define PTH_MUTEX_INITIALIZER { {NULL,NULL}, PTH_MUTEX_INITIALIZED, NULL, 0 } d161 2 a162 2 #define PTH_RWLOCK_INITIALIZER { PTH_RWLOCK_INITIALIZED, PTH_RWLOCK_RD, 0, \ PTH_MUTEX_INITIALIZER, PTH_MUTEX_INITIALIZER } d171 1 a171 1 #define PTH_COND_INITIALIZER { PTH_COND_INITIALIZED } @ 1.62 log @*** empty log message *** @ text @d277 1 @ 1.61 log @*** empty log message *** @ text @d267 1 a267 1 long pth_ctrl(unsigned long query, ...); d270 3 a272 3 pth_attr_t pth_attr(char *name, int prio, unsigned int flags, unsigned int cancelstate, unsigned int stacksize, void *stackaddr); pth_t pth_spawn(pth_attr_t *attr, void *(*func)(void *), void *arg); int pth_once(pth_once_t *oncectrl, void (*constructor)(void *), void *arg); d274 10 a283 10 int pth_equal(pth_t thread1, pth_t thread2); int pth_priority(pth_t thread, int prio); int pth_sigmask(int how, const sigset_t *set, sigset_t *oset); void pth_yield(pth_t to); int pth_nap(pth_time_t naptime); int pth_wait(pth_event_t ev); int pth_cancel(pth_t thread); int pth_detach(pth_t thread); int pth_join(pth_t thread, void **value); void pth_exit(void *value); d286 3 a288 3 int pth_nonblocking(int fd); pth_time_t pth_time(int sec, int usec); pth_time_t pth_timeout(int sec, int usec); d291 1 a291 1 void pth_cancel_state(int newstate, int *oldstate); d295 6 a300 6 pth_event_t pth_event(unsigned long spec, ...); pth_event_t pth_event_concat(pth_event_t ev, ...); pth_event_t pth_event_isolate(pth_event_t ev); pth_event_t pth_event_walk(pth_event_t ev, unsigned int direction); int pth_event_occurred(pth_event_t ev); int pth_event_free(pth_event_t ev, int all); d303 4 a306 4 int pth_key_create(pth_key_t *key, void (*func)(void *)); int pth_key_delete(pth_key_t key); int pth_key_setdata(pth_key_t key, const void *value); void *pth_key_getdata(pth_key_t key); d309 7 a315 7 pth_msgport_t pth_msgport_create(const char *name); void pth_msgport_destroy(pth_msgport_t mp); pth_msgport_t pth_msgport_find(const char *name); int pth_msgport_pending(pth_msgport_t mp); int pth_msgport_put(pth_msgport_t mp, pth_message_t *m); pth_message_t *pth_msgport_get(pth_msgport_t mp); int pth_msgport_reply(pth_message_t *m); d318 2 a319 2 int pth_cleanup_push(void (*func)(void *), void *arg); int pth_cleanup_pop(int execute); d322 9 a330 9 int pth_mutex_init(pth_mutex_t *mutex); int pth_mutex_acquire(pth_mutex_t *mutex, int try, pth_event_t ev); int pth_mutex_release(pth_mutex_t *mutex); int pth_rwlock_init(pth_rwlock_t *rwlock); int pth_rwlock_acquire(pth_rwlock_t *rwlock, int op, int try, pth_event_t ev); int pth_rwlock_release(pth_rwlock_t *rwlock); int pth_cond_init(pth_cond_t *cond); int pth_cond_await(pth_cond_t *cond, pth_mutex_t *mutex, pth_event_t ev); int pth_cond_notify(pth_cond_t *cond, int broadcast); d333 6 a338 6 int pth_sigwait_ev(const sigset_t *set, int *sig, pth_event_t ev); int pth_connect_ev(int s, struct sockaddr *addr, int addrlen, pth_event_t ev); int pth_accept_ev(int s, struct sockaddr *addr, int *addrlen, pth_event_t ev); ssize_t pth_write_ev(int fd, const void *buf, size_t nbytes, pth_event_t ev); ssize_t pth_read_ev(int fd, void *buf, size_t nbytes, pth_event_t ev); ssize_t pth_readline_ev(int fd, void *buf, size_t buflen, pth_event_t ev); d342 9 a350 9 int pth_usleep(unsigned int usec); unsigned int pth_sleep(unsigned int sec); pid_t pth_waitpid(pid_t pid, int *status, int options); int pth_sigwait(const sigset_t *set, int *sig); int pth_connect(int s, struct sockaddr *addr, int addrlen); int pth_accept(int s, struct sockaddr *addr, int *addrlen); ssize_t pth_write(int fd, const void *buf, size_t nbytes); ssize_t pth_read(int fd, void *buf, size_t nbytes); ssize_t pth_readline(int fd, void *buf, size_t buflen); @ 1.60 log @*** empty log message *** @ text @d326 1 a326 1 int pth_rwlock_acquire(pth_rwlock_t *rwlock, int op, pth_event_t ev); @ 1.59 log @*** empty log message *** @ text @d300 1 a300 1 void pth_event_free(pth_event_t ev, int all); @ 1.58 log @*** empty log message *** @ text @d318 2 a319 2 void pth_cleanup_push(void (*func)(void *), void *arg); void pth_cleanup_pop(int execute); @ 1.57 log @*** empty log message *** @ text @d272 1 a272 1 void pth_once(pth_once_t *oncectrl, void (*constructor)(void *), void *arg); d275 1 a275 1 void pth_priority(pth_t thread, int prio); d278 1 a278 1 void pth_nap(pth_time_t naptime); @ 1.56 log @*** empty log message *** @ text @d323 1 a323 1 int pth_mutex_acquire(pth_mutex_t *mutex, pth_event_t ev); @ 1.55 log @*** empty log message *** @ text @d276 2 a277 1 void pth_yield(void); @ 1.54 log @*** empty log message *** @ text @d152 1 d154 1 d157 7 d166 1 d170 1 d245 10 d320 1 a320 1 /* mutex functions */ d322 1 a322 1 int pth_mutex_acquire(pth_mutex_t *mutex, int poll, pth_event_t ev); d324 3 a326 3 pth_t pth_mutex_holder(pth_mutex_t *mutex); /* condition variable functions */ d328 1 a328 1 int pth_cond_wait(pth_cond_t *cond, pth_mutex_t *mutex, pth_event_t ev); @ 1.53 log @*** empty log message *** @ text @d106 4 a109 3 #define PTH_EVENT_TID 1<<6 #define PTH_EVENT_PID 1<<7 #define PTH_EVENT_FUNC 1<<8 d153 8 a160 1 #define PTH_MUTEX_INITIALIZER { PTH_MUTEX_INITIALIZED, NULL, 0 } d228 4 a231 3 unsigned int state; pth_t owner; unsigned long count; d234 5 d304 5 @ 1.52 log @*** empty log message *** @ text @d289 1 @ 1.51 log @*** empty log message *** @ text @d287 2 a288 2 int pth_mutex_lock(pth_mutex_t *mutex, int poll, pth_event_t ev); int pth_mutex_unlock(pth_mutex_t *mutex); @ 1.50 log @*** empty log message *** @ text @d105 4 a108 3 #define PTH_EVENT_TID 1<<5 #define PTH_EVENT_PID 1<<6 #define PTH_EVENT_FUNC 1<<7 d149 5 d214 9 a222 1 int state; d225 1 d284 5 @ 1.49 log @*** empty log message *** @ text @d230 1 @ 1.48 log @*** empty log message *** @ text @d145 1 d163 1 d220 1 a220 1 pth_attr_t pth_attr(char *name, int prio, unsigned int flags, unsigned int stacksize, void *stackaddr); @ 1.47 log @*** empty log message *** @ text @d227 1 a236 1 int pth_cancel(pth_t thread); @ 1.46 log @*** empty log message *** @ text @a219 3 void pth_cancel_state(int newstate, int *oldstate); void pth_cancel_point(void); int pth_cancel(pth_t thread); d234 5 @ 1.45 log @*** empty log message *** @ text @d140 7 d220 2 @ 1.44 log @*** empty log message *** @ text @d213 1 @ 1.43 log @*** empty log message *** @ text @d251 4 @ 1.42 log @*** empty log message *** @ text @d61 2 a62 2 #define BEGIN_PROTOTYPES extern "C" { #define END_PROTOTYPES } d64 2 a65 2 #define BEGIN_PROTOTYPES /*nop*/ #define END_PROTOTYPES /*nop*/ d140 2 a204 2 BEGIN_PROTOTYPES d271 1 a271 1 END_PROTOTYPES @ 1.41 log @*** empty log message *** @ text @d263 1 a264 1 pid_t pth_waitpid(pid_t pid, int *status, int options); @ 1.40 log @*** empty log message *** @ text @d252 1 @ 1.39 log @*** empty log message *** @ text @d102 1 a102 1 #define PTH_EVENT_SIG 1<<2 d262 1 @ 1.38 log @*** empty log message *** @ text @d129 2 a130 2 #define PTH_WALK_NEXT 1 #define PTH_WALK_PREV 2 d232 1 a232 1 pth_event_t pth_event_walk(pth_event_t ev, int direction); @ 1.37 log @*** empty log message *** @ text @d37 1 d102 1 a102 1 #define PTH_EVENT_IRQ 1<<2 @ 1.36 log @*** empty log message *** @ text @d58 81 d141 1 a141 1 typedef void *pth_t; /* opaque for application */ d156 3 d161 1 a161 1 typedef void *pth_event_t; /* opaque for application */ a175 1 #define PTH_RING_INIT { NULL } a198 6 /* the key type */ typedef int pth_key_t; #define PTH_KEY_INIT -1 #define PTH_KEYS_MAX 256 #define PTH_DESTRUCTOR_ITERATIONS 4 d202 1 a202 76 /* the failure value when a pth_t is returned */ #define PTH_FAIL (pth_t)(0) /* the default value when a pth_attr_t is used */ #define PTH_ATTR_NULL (pth_attr_t *)(0) /* values for the pth_attr() flags */ #define PTH_FLAG_NONE 0 #define PTH_FLAG_NOJOIN 1<<1 /* do not block under any circumstances */ #define PTH_NOWAIT (pth_time(0,0)) /* block infinite */ #define PTH_NOTIME (pth_time(-1,-1)) /* queries for pth_ctrl() */ #define PTH_CTRL_GETTHREADS (PTH_CTRL_GETTHREADS_NEW|PTH_CTRL_GETTHREADS_READY|PTH_CTRL_GETTHREADS_RUNNING|PTH_CTRL_GETTHREADS_WAITING|PTH_CTRL_GETTHREADS_DEAD) #define PTH_CTRL_GETTHREADS_NEW 1<<1 #define PTH_CTRL_GETTHREADS_READY 1<<2 #define PTH_CTRL_GETTHREADS_RUNNING 1<<3 #define PTH_CTRL_GETTHREADS_WAITING 1<<4 #define PTH_CTRL_GETTHREADS_DEAD 1<<5 #define PTH_CTRL_GETAVLOAD 1<<6 #define PTH_CTRL_GETPRIO 1<<10 #define PTH_CTRL_GETNAME 1<<11 /* values for pth_priority() */ #define PTH_PRIO_MAX +5 #define PTH_PRIO_STD 0 #define PTH_PRIO_MIN -5 /* event chaining identifier */ #define PTH_MODE_REUSE 1<<0 #define PTH_MODE_CHAIN 1<<1 #define PTH_MODE_STATIC 1<<2 /* event subject classes */ #define PTH_EVENT_FD 1<<3 #define PTH_EVENT_IRQ 1<<4 #define PTH_EVENT_TIME 1<<5 #define PTH_EVENT_MSG 1<<6 #define PTH_EVENT_TID 1<<7 #define PTH_EVENT_PID 1<<8 #define PTH_EVENT_FUNC 1<<9 /* event happenings */ #define PTH_UNTIL_AVAILABLE 1<<10 #define PTH_UNTIL_OCCURRED 1<<11 #define PTH_UNTIL_READABLE 1<<12 #define PTH_UNTIL_WRITEABLE 1<<13 #define PTH_UNTIL_EXCEPTION 1<<14 #define PTH_UNTIL_ELAPSED 1<<15 #define PTH_UNTIL_RECEIVED 1<<16 #define PTH_UNTIL_STATENEW 1<<17 #define PTH_UNTIL_NEW 1<<18 #define PTH_UNTIL_READY 1<<19 #define PTH_UNTIL_WAITING 1<<21 #define PTH_UNTIL_DEAD 1<<22 #define PTH_UNTIL_FULFILLED 1<<23 /* event deallocation types */ #define PTH_FREE_THIS 1 #define PTH_FREE_ALL 2 /* event walking directions */ #define PTH_WALK_NEXT 1 #define PTH_WALK_PREV 2 /* once control init value */ #define PTH_ONCE_NEEDS_INIT 0 #define PTH_ONCE_DONE_INIT 1 #define PTH_ONCE_INIT { PTH_ONCE_NEEDS_INIT } #ifdef __cplusplus extern "C" { #endif d268 1 a268 3 #ifdef __cplusplus } #endif @ 1.35 log @*** empty log message *** @ text @d249 1 a249 1 int pth_connect_ev(int s, const struct sockaddr *addr, int addrlen, pth_event_t ev); d260 1 a260 1 int pth_connect(int s, const struct sockaddr *addr, int addrlen); @ 1.34 log @*** empty log message *** @ text @d20 1 a20 1 ** License along with this library; if not, write to the Free @ 1.33 log @*** empty log message *** @ text @d39 1 @ 1.32 log @*** empty log message *** @ text @d71 1 d207 1 a207 1 pth_attr_t pth_attr(char *name, int prio, unsigned int flags, unsigned int stacksize); @ 1.31 log @*** empty log message *** @ text @d214 1 a214 1 int pth_wait(pth_event_t *ev_waiting, pth_event_t *ev_occurred); @ 1.30 log @*** empty log message *** @ text @d221 1 @ 1.29 log @*** empty log message *** @ text @d246 1 a247 1 int pth_connect_ev(int s, const struct sockaddr *addr, int addrlen, pth_event_t ev); d257 1 a258 1 int pth_connect(int s, const struct sockaddr *addr, int addrlen); @ 1.28 log @*** empty log message *** @ text @d246 2 d258 1 @ 1.27 log @*** empty log message *** @ text @d1 2 a2 1 /* ** pth.h -- PTH public API definitions @ 1.26 log @*** empty log message *** @ text @d115 1 d156 1 @ 1.25 log @*** empty log message *** @ text @a175 1 #define PTH_UNTIL_RUNNING 1<<20 a191 14 /* errno support */ #ifdef __cplusplus extern "C" { int *__pth_errno(void); } #else int *__pth_errno(void); #endif #ifndef _PTH_PRIVATE #define pth_errno (*__pth_errno()) #ifdef errno #undef errno #endif #define errno pth_errno #endif @ 1.24 log @*** empty log message *** @ text @d167 1 a167 1 #define PTH_UNTIL_OCCURED 1<<11 d226 1 a226 1 int pth_wait(pth_event_t *ev_waiting, pth_event_t *ev_occured); d239 1 a239 1 int pth_event_occured(pth_event_t ev); @ 1.23 log @*** empty log message *** @ text @d1 1 a1 2 /* ** pth.h -- PTH public API definitions a69 1 int joinable; d125 5 a129 1 #define PTH_DEFATTR (pth_attr_t *)(0) d144 2 d218 1 a218 1 pth_attr_t pth_attr(char *name, int prio, unsigned int flags, unsigned int stacksize, int joinable); d226 1 a226 1 int pth_wait(pth_event_t *ev_pending, pth_event_t *ev_occured); @ 1.22 log @*** empty log message *** @ text @d6 1 a6 1 ** This file is part of PTH, a non-preemtive thread scheduling library @ 1.21 log @*** empty log message *** @ text @d259 1 @ 1.20 log @*** empty log message *** @ text @d134 8 a141 7 /* values for counting threads via pth_stat() */ #define PTH_STAT_NEW 1<<0 #define PTH_STAT_READY 1<<1 #define PTH_STAT_RUNNING 1<<2 #define PTH_STAT_WAITING 1<<3 #define PTH_STAT_DEAD 1<<4 #define PTH_STAT_TOTAL (PTH_STAT_NEW|PTH_STAT_READY|PTH_STAT_RUNNING|PTH_STAT_WAITING|PTH_STAT_DEAD) d211 1 a211 2 unsigned int pth_stat(int type); float pth_load(void); @ 1.19 log @*** empty log message *** @ text @d211 1 a211 1 float pth_averageload(void); @ 1.18 log @*** empty log message *** @ text @a189 1 #ifndef _PTH_PRIVATE d195 1 @ 1.17 log @*** empty log message *** @ text @d190 1 a195 1 #ifndef _PTH_PRIVATE d211 1 @ 1.16 log @*** empty log message *** @ text @d189 14 d208 1 a208 1 void pth_init(void); @ 1.15 log @*** empty log message *** @ text @a0 40 /* ==================================================================== * Copyright (c) 1999 Ralf S. Engelschall. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by * Ralf S. Engelschall ." * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by * Ralf S. Engelschall ." * * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== */ d2 21 a22 2 ** Non-Preemtive Scheduler Library (PTH) ** pth.h -- public API definition @ 1.14 log @*** empty log message *** @ text @d214 1 a214 1 /* library functions */ d259 6 a264 1 /* high level replacement functions */ a271 5 /* generalized variants of the replacement functions */ ssize_t pth_write_ev(int fd, const void *buf, size_t nbytes, pth_event_t ev); ssize_t pth_read_ev(int fd, void *buf, size_t nbytes, pth_event_t ev); ssize_t pth_readline_ev(int fd, void *buf, size_t buflen, pth_event_t ev); @ 1.13 log @*** empty log message *** @ text @d222 1 d226 4 a229 1 void pth_once(pth_once_t *oncectrl, void (*constructor)(void *), void *arg); a230 2 int pth_join(pth_t thread, void **value); void pth_yield(void); a234 1 void pth_nap(pth_time_t naptime); a236 1 int pth_wait(pth_event_t *ev_pending, pth_event_t *ev_occured); d265 4 a269 1 ssize_t pth_read(int fd, void *buf, size_t nbytes); a270 1 ssize_t pth_readline(int fd, void *buf, size_t buflen); @ 1.12 log @*** empty log message *** @ text @d49 1 d54 1 d59 6 a70 1 a77 5 /* type fallbacks */ @@FALLBACK_PID_T@@ @@FALLBACK_SIZE_T@@ @@FALLBACK_SSIZE_T@@ d80 1 a80 1 typedef void *pth_t; d97 1 a97 1 typedef void *pth_event_t; d116 1 a116 1 typedef void *pth_msgport_t; d152 2 d161 1 a161 2 #define PTH_STAT_TOTAL \ (PTH_STAT_NEW|PTH_STAT_READY|PTH_STAT_RUNNING|PTH_STAT_WAITING|PTH_STAT_DEAD) a209 2 /* API functions */ d214 1 d218 2 d225 1 d229 3 a233 2 int pth_nonblocking(int fd); void pth_once(pth_once_t *oncectrl, void (*constructor)(void *), void *arg); d235 1 d239 1 d244 1 d247 2 a248 2 int pth_setspecific(pth_key_t key, const void *value); void *pth_getspecific(pth_key_t key); d250 1 d254 4 a257 4 int pth_message_pending(pth_msgport_t mp); int pth_message_put(pth_msgport_t mp, pth_message_t *m); pth_message_t *pth_message_get(pth_msgport_t mp); int pth_message_reply(pth_message_t *m); d259 1 d265 1 d267 1 d269 1 @ 1.11 log @*** empty log message *** @ text @d225 2 d228 2 a233 1 int pth_wait(pth_event_t *ev_pending, pth_event_t *ev_occured); a234 2 int pth_nonblocking(int fd); void pth_nap(pth_time_t naptime); @ 1.10 log @*** empty log message *** @ text @d213 21 a233 21 void pth_init(void); void pth_kill(void); unsigned int pth_stat(int type); pth_attr_t pth_attr(char *name, int prio, unsigned int flags, unsigned int stacksize, int joinable); pth_t pth_spawn(pth_attr_t *attr, void *(*func)(void *), void *arg); pth_t pth_self(void); int pth_equal(pth_t thread1, pth_t thread2); void pth_priority(pth_t thread, int prio); void pth_exit(void *value); int pth_join(pth_t thread, void **value); void pth_yield(void); pth_time_t pth_time(int sec, int usec); void pth_once(pth_once_t *oncectrl, void (*constructor)(void *), void *arg); pth_event_t pth_event(unsigned long spec, ...); pth_event_t pth_event_concat(pth_event_t ev, ...); pth_event_t pth_event_walk(pth_event_t ev, int direction); int pth_event_occured(pth_event_t ev); int pth_wait(pth_event_t *ev_pending, pth_event_t *ev_occured); void pth_event_free(pth_event_t ev, int all); int pth_nonblocking(int fd); void pth_nap(pth_time_t naptime); d235 4 a238 4 int pth_key_create(pth_key_t *key, void (*func)(void *)); int pth_key_delete(pth_key_t key); int pth_setspecific(pth_key_t key, const void *value); void *pth_getspecific(pth_key_t key); d248 7 a254 7 int pth_usleep(unsigned int usec); unsigned int pth_sleep(unsigned int sec); pid_t pth_waitpid(pid_t pid, int *status, int options); int pth_accept(int s, struct sockaddr *addr, int *addrlen); ssize_t pth_write(int fd, const void *buf, size_t nbytes); ssize_t pth_read(int fd, void *buf, size_t nbytes); ssize_t pth_readline(int fd, void *buf, size_t buflen); @ 1.9 log @*** empty log message *** @ text @d100 12 d119 9 d234 1 d239 8 @ 1.8 log @*** empty log message *** @ text @d187 5 d225 4 @ 1.7 log @*** empty log message *** @ text @d216 2 d219 1 a219 2 ssize_t pth_write(int fd, const void *buf, size_t nbytes); int pth_accept(int s, struct sockaddr *addr, int *addrlen); @ 1.6 log @*** empty log message *** @ text @d115 2 a199 2 void pth_store(pth_t thread, void *value, void (*destructor)(void*)); void *pth_retrieve(pth_t thread); d208 4 @ 1.5 log @*** empty log message *** @ text @d113 3 @ 1.4 log @*** empty log message *** @ text @d107 6 d176 5 d194 1 @ 1.3 log @*** empty log message *** @ text @d192 4 a195 1 int pth_sleep(pth_time_t offset); @ 1.2 log @*** empty log message *** @ text @d191 1 a191 1 int pth_asynchronize(int fd); @ 1.1 log @Initial revision @ text @d49 1 d51 1 @ 1.1.1.1 log @Import of PTH into CVS @ text @@