1 /* lthread.h - ldap threads header file */
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 /* Do not use #elif. K&R does not support it. */
55 #else /* !HAVE_PTHREADS */
56 #ifdef HAVE_MACH_CTHREADS
57 /**********************************
59 * definitions for Mach CThreads *
61 **********************************/
63 #include <mach/cthreads.h>
67 typedef cthread_fn_t VFP;
68 typedef int pthread_attr_t;
69 typedef cthread_t pthread_t;
71 /* default attr states */
72 #define pthread_mutexattr_default NULL
73 #define pthread_condattr_default NULL
75 /* thread state - joinable or not */
76 #define PTHREAD_CREATE_JOINABLE 0
77 #define PTHREAD_CREATE_DETACHED 1
78 /* thread scope - who is in scheduling pool */
79 #define PTHREAD_SCOPE_PROCESS 0
80 #define PTHREAD_SCOPE_SYSTEM 1
82 /* mutex attributes and mutex type */
83 typedef int pthread_mutexattr_t;
84 typedef struct mutex pthread_mutex_t;
86 /* mutex and condition variable scope - process or system */
87 #define PTHREAD_SHARE_PRIVATE 0
88 #define PTHREAD_SHARE_PROCESS 1
90 /* condition variable attributes and condition variable type */
91 typedef int pthread_condattr_t;
92 typedef struct condition pthread_cond_t;
96 #else /* !HAVE_MACH_CTHREADS */
98 /**************************************
100 * thread definitions for Solaris LWP *
102 **************************************/
109 typedef void *(*VFP)();
111 /* default attr states */
112 #define pthread_mutexattr_default NULL
113 #define pthread_condattr_default NULL
115 /* thread state - joinable or not */
116 #define PTHREAD_CREATE_JOINABLE 0
117 #define PTHREAD_CREATE_DETACHED THR_DETACHED
118 /* thread scope - who is in scheduling pool */
119 #define PTHREAD_SCOPE_PROCESS 0
120 #define PTHREAD_SCOPE_SYSTEM THR_BOUND
121 /* mutex and condition variable scope - process or system */
122 #define PTHREAD_SHARE_PRIVATE USYNC_THREAD
123 #define PTHREAD_SHARE_PROCESS USYNC_PROCESS
126 #if !defined(__SunOS_5_6)
127 /* thread attributes and thread type */
128 typedef int pthread_attr_t;
129 typedef thread_t pthread_t;
131 /* mutex attributes and mutex type */
132 typedef int pthread_mutexattr_t;
133 typedef mutex_t pthread_mutex_t;
135 /* condition variable attributes and condition variable type */
136 typedef int pthread_condattr_t;
137 typedef cond_t pthread_cond_t;
138 #endif /* ! sunos56 */
142 #else /* !HAVE_THR */
144 /*************************************
146 * thread definitions for SunOS LWP *
148 *************************************/
151 #include <lwp/stackdep.h>
155 stkalign_t *get_stack( int *stacknop );
156 void free_stack( int *stackno );
158 typedef void *(*VFP)();
160 /* thread attributes and thread type */
161 typedef int pthread_attr_t;
162 typedef thread_t pthread_t;
164 /* default attr states */
165 #define pthread_mutexattr_default NULL
166 #define pthread_condattr_default NULL
168 /* thread state - joinable or not */
169 #define PTHREAD_CREATE_JOINABLE 0
170 #define PTHREAD_CREATE_DETACHED 1
171 /* thread scope - who is in scheduling pool */
172 #define PTHREAD_SCOPE_PROCESS 0
173 #define PTHREAD_SCOPE_SYSTEM 1
175 /* mutex attributes and mutex type */
176 typedef int pthread_mutexattr_t;
177 typedef mon_t pthread_mutex_t;
179 /* mutex and condition variable scope - process or system */
180 #define PTHREAD_SHARE_PRIVATE 0
181 #define PTHREAD_SHARE_PROCESS 1
183 /* condition variable attributes and condition variable type */
184 typedef int pthread_condattr_t;
185 typedef struct lwpcv {
192 #else /* !HAVE_LWP */
193 /***********************************
195 * thread definitions for no *
196 * underlying library support *
198 ***********************************/
206 #ifndef PREEMPTIVE_THREADS
207 /* treat no threads as preemptive */
208 #define PREEMPTIVE_THREADS 1
211 typedef void *(*VFP)();
213 /* thread attributes and thread type */
214 typedef int pthread_attr_t;
215 typedef int pthread_t;
217 /* default attr states */
218 #define pthread_mutexattr_default NULL
219 #define pthread_condattr_default NULL
221 /* thread state - joinable or not */
222 #define PTHREAD_CREATE_JOINABLE 0
223 #define PTHREAD_CREATE_DETACHED 0
224 /* thread scope - who is in scheduling pool */
225 #define PTHREAD_SCOPE_PROCESS 0
226 #define PTHREAD_SCOPE_SYSTEM 0
228 /* mutex attributes and mutex type */
229 typedef int pthread_mutexattr_t;
230 typedef int pthread_mutex_t;
232 /* mutex and condition variable scope - process or system */
233 #define PTHREAD_SHARE_PRIVATE 0
234 #define PTHREAD_SHARE_PROCESS 0
236 /* condition variable attributes and condition variable type */
237 typedef int pthread_condattr_t;
238 typedef int pthread_cond_t;
242 #endif /* HAVE_LWP */
243 #endif /* HAVE_THR */
244 #endif /* HAVE_MACH_CTHREADS */
245 #endif /* HAVE_PTHREADS */
246 #endif /* _LTHREAD_H */