1 /* lthread.h - ldap threads header file */
8 #if defined( HAVE_PTHREADS )
9 /**********************************
11 * definitions for POSIX Threads *
13 **********************************/
22 #if !defined( HAVE_PTHREAD_ATTR_INIT ) && \
23 defined( HAVE_PTHREAD_ATTR_CREATE )
24 #define pthread_attr_init( a ) pthread_attr_create( a )
27 #if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \
28 defined( HAVE_PTHREAD_ATTR_DELETE )
29 #define pthread_attr_destroy( a ) pthread_attr_delete( a )
32 #if !defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) && \
33 defined( HAVE_PTHREAD_ATTR_SETDETACH_NP )
34 #define pthread_attr_setdetachstate( a, b ) \
35 pthread_attr_setdetach_np( a, b )
38 #ifndef HAVE_PTHREAD_KILL
39 /* missing pthread_kill(), define prototype */
40 LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig ));
43 #ifndef HAVE_PTHREADS_D4
44 #define pthread_mutexattr_default NULL
45 #define pthread_condattr_default NULL
47 #ifdef HAVE_SCHED_YIELD
48 #define pthread_yield sched_yield
54 #elif defined ( HAVE_MACH_CTHREADS )
55 /**********************************
57 * definitions for Mach CThreads *
59 **********************************/
61 #include <mach/cthreads.h>
65 typedef cthread_fn_t VFP;
66 typedef int pthread_attr_t;
67 typedef cthread_t pthread_t;
69 /* default attr states */
70 #define pthread_mutexattr_default NULL
71 #define pthread_condattr_default NULL
73 /* thread state - joinable or not */
74 #define PTHREAD_CREATE_JOINABLE 0
75 #define PTHREAD_CREATE_DETACHED 1
76 /* thread scope - who is in scheduling pool */
77 #define PTHREAD_SCOPE_PROCESS 0
78 #define PTHREAD_SCOPE_SYSTEM 1
80 /* mutex attributes and mutex type */
81 typedef int pthread_mutexattr_t;
82 typedef struct mutex pthread_mutex_t;
84 /* mutex and condition variable scope - process or system */
85 #define PTHREAD_SHARE_PRIVATE 0
86 #define PTHREAD_SHARE_PROCESS 1
88 /* condition variable attributes and condition variable type */
89 typedef int pthread_condattr_t;
90 typedef struct condition pthread_cond_t;
94 #elif defined( HAVE_THR )
95 /**************************************
97 * thread definitions for Solaris LWP *
99 **************************************/
106 typedef void *(*VFP)();
108 /* default attr states */
109 #define pthread_mutexattr_default NULL
110 #define pthread_condattr_default NULL
112 /* thread state - joinable or not */
113 #define PTHREAD_CREATE_JOINABLE 0
114 #define PTHREAD_CREATE_DETACHED THR_DETACHED
115 /* thread scope - who is in scheduling pool */
116 #define PTHREAD_SCOPE_PROCESS 0
117 #define PTHREAD_SCOPE_SYSTEM THR_BOUND
118 /* mutex and condition variable scope - process or system */
119 #define PTHREAD_SHARE_PRIVATE USYNC_THREAD
120 #define PTHREAD_SHARE_PROCESS USYNC_PROCESS
122 /* thread attributes and thread type */
123 typedef int pthread_attr_t;
124 typedef thread_t pthread_t;
126 /* mutex attributes and mutex type */
127 typedef int pthread_mutexattr_t;
128 typedef mutex_t pthread_mutex_t;
130 /* condition variable attributes and condition variable type */
131 typedef int pthread_condattr_t;
132 typedef cond_t pthread_cond_t;
136 #elif defined( HAVE_LWP )
137 /*************************************
139 * thread definitions for SunOS LWP *
141 *************************************/
144 #include <lwp/stackdep.h>
148 stkalign_t *get_stack( int *stacknop );
149 void free_stack( int *stackno );
151 typedef void *(*VFP)();
153 /* thread attributes and thread type */
154 typedef int pthread_attr_t;
155 typedef thread_t pthread_t;
157 /* default attr states */
158 #define pthread_mutexattr_default NULL
159 #define pthread_condattr_default NULL
161 /* thread state - joinable or not */
162 #define PTHREAD_CREATE_JOINABLE 0
163 #define PTHREAD_CREATE_DETACHED 1
164 /* thread scope - who is in scheduling pool */
165 #define PTHREAD_SCOPE_PROCESS 0
166 #define PTHREAD_SCOPE_SYSTEM 1
168 /* mutex attributes and mutex type */
169 typedef int pthread_mutexattr_t;
170 typedef mon_t pthread_mutex_t;
172 /* mutex and condition variable scope - process or system */
173 #define PTHREAD_SHARE_PRIVATE 0
174 #define PTHREAD_SHARE_PROCESS 1
176 /* condition variable attributes and condition variable type */
177 typedef int pthread_condattr_t;
178 typedef struct lwpcv {
185 #elif HAVE_NT_THREADS
190 typedef void (*VFP)(void*);
192 /* thread attributes and thread type */
193 typedef int pthread_attr_t;
194 typedef HANDLE pthread_t;
196 /* default attr states */
197 #define pthread_mutexattr_default NULL
198 #define pthread_condattr_default NULL
200 /* thread state - joinable or not */
201 #define PTHREAD_CREATE_JOINABLE 0
202 #define PTHREAD_CREATE_DETACHED 0
203 /* thread scope - who is in scheduling pool */
204 #define PTHREAD_SCOPE_PROCESS 0
205 #define PTHREAD_SCOPE_SYSTEM 0
207 /* mutex attributes and mutex type */
208 typedef int pthread_mutexattr_t;
209 typedef HANDLE pthread_mutex_t;
211 /* mutex and condition variable scope - process or system */
212 #define PTHREAD_SHARE_PRIVATE USYNC_THREAD
213 #define PTHREAD_SHARE_PROCESS USYNC_PROCESS
215 /* condition variable attributes and condition variable type */
216 typedef int pthread_condattr_t;
217 typedef HANDLE pthread_cond_t;
223 /***********************************
225 * thread definitions for no *
226 * underlying library support *
228 ***********************************/
236 typedef void *(*VFP)();
238 /* thread attributes and thread type */
239 typedef int pthread_attr_t;
240 typedef int pthread_t;
242 /* default attr states */
243 #define pthread_mutexattr_default NULL
244 #define pthread_condattr_default NULL
246 /* thread state - joinable or not */
247 #define PTHREAD_CREATE_JOINABLE 0
248 #define PTHREAD_CREATE_DETACHED 0
249 /* thread scope - who is in scheduling pool */
250 #define PTHREAD_SCOPE_PROCESS 0
251 #define PTHREAD_SCOPE_SYSTEM 0
253 /* mutex attributes and mutex type */
254 typedef int pthread_mutexattr_t;
255 typedef int pthread_mutex_t;
257 /* mutex and condition variable scope - process or system */
258 #define PTHREAD_SHARE_PRIVATE 0
259 #define PTHREAD_SHARE_PROCESS 0
261 /* condition variable attributes and condition variable type */
262 typedef int pthread_condattr_t;
263 typedef int pthread_cond_t;
267 #endif /* no threads support */
268 #endif /* _LTHREAD_H */