2 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
5 * Redistribution and use in source and binary forms are permitted only
6 * as authorized by the OpenLDAP Public License. A copy of this
7 * license is available at http://www.OpenLDAP.org/license.html or
8 * in file LICENSE in the top-level directory of the distribution.
10 /* lthread.h - ldap threads header file */
17 #if defined( HAVE_PTHREADS )
18 /**********************************
20 * definitions for POSIX Threads *
22 **********************************/
31 #if !defined( HAVE_PTHREAD_ATTR_INIT ) && \
32 defined( HAVE_PTHREAD_ATTR_CREATE )
33 #define pthread_attr_init( a ) pthread_attr_create( a )
36 #if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \
37 defined( HAVE_PTHREAD_ATTR_DELETE )
38 #define pthread_attr_destroy( a ) pthread_attr_delete( a )
41 #if !defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) && \
42 defined( HAVE_PTHREAD_ATTR_SETDETACH_NP )
43 #define pthread_attr_setdetachstate( a, b ) \
44 pthread_attr_setdetach_np( a, b )
47 #ifndef HAVE_PTHREAD_KILL
48 /* missing pthread_kill(), define prototype */
49 LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig ));
52 #ifndef HAVE_PTHREADS_D4
53 #define pthread_mutexattr_default NULL
54 #define pthread_condattr_default NULL
56 #ifdef HAVE_SCHED_YIELD
57 #define pthread_yield sched_yield
63 #elif defined ( HAVE_MACH_CTHREADS )
64 /**********************************
66 * definitions for Mach CThreads *
68 **********************************/
70 #include <mach/cthreads.h>
74 typedef cthread_fn_t VFP;
75 typedef int pthread_attr_t;
76 typedef cthread_t pthread_t;
78 /* default attr states */
79 #define pthread_mutexattr_default NULL
80 #define pthread_condattr_default NULL
82 /* thread state - joinable or not */
83 #define PTHREAD_CREATE_JOINABLE 0
84 #define PTHREAD_CREATE_DETACHED 1
85 /* thread scope - who is in scheduling pool */
86 #define PTHREAD_SCOPE_PROCESS 0
87 #define PTHREAD_SCOPE_SYSTEM 1
89 /* mutex attributes and mutex type */
90 typedef int pthread_mutexattr_t;
91 typedef struct mutex pthread_mutex_t;
93 /* mutex and condition variable scope - process or system */
94 #define PTHREAD_SHARE_PRIVATE 0
95 #define PTHREAD_SHARE_PROCESS 1
97 /* condition variable attributes and condition variable type */
98 typedef int pthread_condattr_t;
99 typedef struct condition pthread_cond_t;
103 #elif defined( HAVE_THR )
104 /**************************************
106 * thread definitions for Solaris LWP *
108 **************************************/
115 typedef void *(*VFP)();
117 /* default attr states */
118 #define pthread_mutexattr_default NULL
119 #define pthread_condattr_default NULL
121 /* thread state - joinable or not */
122 #define PTHREAD_CREATE_JOINABLE 0
123 #define PTHREAD_CREATE_DETACHED THR_DETACHED
124 /* thread scope - who is in scheduling pool */
125 #define PTHREAD_SCOPE_PROCESS 0
126 #define PTHREAD_SCOPE_SYSTEM THR_BOUND
127 /* mutex and condition variable scope - process or system */
128 #define PTHREAD_SHARE_PRIVATE USYNC_THREAD
129 #define PTHREAD_SHARE_PROCESS USYNC_PROCESS
131 /* thread attributes and thread type */
132 typedef int pthread_attr_t;
133 typedef thread_t pthread_t;
135 /* mutex attributes and mutex type */
136 typedef int pthread_mutexattr_t;
137 typedef mutex_t pthread_mutex_t;
139 /* condition variable attributes and condition variable type */
140 typedef int pthread_condattr_t;
141 typedef cond_t pthread_cond_t;
145 #elif defined( HAVE_LWP )
146 /*************************************
148 * thread definitions for SunOS LWP *
150 *************************************/
153 #include <lwp/stackdep.h>
157 stkalign_t *get_stack( int *stacknop );
158 void free_stack( int *stackno );
160 typedef void *(*VFP)();
162 /* thread attributes and thread type */
163 typedef int pthread_attr_t;
164 typedef thread_t pthread_t;
166 /* default attr states */
167 #define pthread_mutexattr_default NULL
168 #define pthread_condattr_default NULL
170 /* thread state - joinable or not */
171 #define PTHREAD_CREATE_JOINABLE 0
172 #define PTHREAD_CREATE_DETACHED 1
173 /* thread scope - who is in scheduling pool */
174 #define PTHREAD_SCOPE_PROCESS 0
175 #define PTHREAD_SCOPE_SYSTEM 1
177 /* mutex attributes and mutex type */
178 typedef int pthread_mutexattr_t;
179 typedef mon_t pthread_mutex_t;
181 /* mutex and condition variable scope - process or system */
182 #define PTHREAD_SHARE_PRIVATE 0
183 #define PTHREAD_SHARE_PROCESS 1
185 /* condition variable attributes and condition variable type */
186 typedef int pthread_condattr_t;
187 typedef struct lwpcv {
196 /***********************************
198 * thread definitions for no *
199 * underlying library support *
201 ***********************************/
209 typedef void *(*VFP)();
211 /* thread attributes and thread type */
212 typedef int pthread_attr_t;
213 typedef int pthread_t;
215 /* default attr states */
216 #define pthread_mutexattr_default NULL
217 #define pthread_condattr_default NULL
219 /* thread state - joinable or not */
220 #define PTHREAD_CREATE_JOINABLE 0
221 #define PTHREAD_CREATE_DETACHED 0
222 /* thread scope - who is in scheduling pool */
223 #define PTHREAD_SCOPE_PROCESS 0
224 #define PTHREAD_SCOPE_SYSTEM 0
226 /* mutex attributes and mutex type */
227 typedef int pthread_mutexattr_t;
228 typedef int pthread_mutex_t;
230 /* mutex and condition variable scope - process or system */
231 #define PTHREAD_SHARE_PRIVATE 0
232 #define PTHREAD_SHARE_PROCESS 0
234 /* condition variable attributes and condition variable type */
235 typedef int pthread_condattr_t;
236 typedef int pthread_cond_t;
240 #endif /* no threads support */
241 #endif /* _LTHREAD_H */