]> git.sur5r.net Git - openldap/blob - include/lthread.h
Mongo patch: changes from -devel from 981105 snap to present
[openldap] / include / lthread.h
1 /* lthread.h - ldap threads header file */
2
3 #ifndef _LTHREAD_H
4 #define _LTHREAD_H
5
6 #include "portable.h"
7
8 #if defined( HAVE_PTHREADS )
9 /**********************************
10  *                                *
11  * definitions for POSIX Threads  *
12  *                                *
13  **********************************/
14
15 #include <pthread.h>
16 #ifdef HAVE_SCHED_H
17 #include <sched.h>
18 #endif
19
20 LDAP_BEGIN_DECL
21
22 #if !defined( HAVE_PTHREAD_ATTR_INIT ) && \
23         defined( HAVE_PTHREAD_ATTR_CREATE )
24 #define pthread_attr_init( a )          pthread_attr_create( a )
25 #endif
26
27 #if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \
28         defined( HAVE_PTHREAD_ATTR_DELETE )
29 #define pthread_attr_destroy( a )       pthread_attr_delete( a )
30 #endif
31
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 )
36 #endif
37
38 #ifndef HAVE_PTHREAD_KILL
39 /* missing pthread_kill(), define prototype */
40 LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig ));
41 #endif
42
43 #ifndef HAVE_PTHREADS_D4
44 #define pthread_mutexattr_default       NULL
45 #define pthread_condattr_default        NULL
46
47 #ifdef HAVE_SCHED_YIELD
48 #define pthread_yield sched_yield
49 #endif
50 #endif
51
52 LDAP_END_DECL
53
54 #elif defined ( HAVE_MACH_CTHREADS )
55 /**********************************
56  *                                *
57  * definitions for Mach CThreads  *
58  *                                *
59  **********************************/
60
61 #include <mach/cthreads.h>
62
63 LDAP_BEGIN_DECL
64
65 typedef cthread_fn_t    VFP;
66 typedef int             pthread_attr_t;
67 typedef cthread_t       pthread_t;
68
69 /* default attr states */
70 #define pthread_mutexattr_default       NULL
71 #define pthread_condattr_default        NULL
72
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
79
80 /* mutex attributes and mutex type */
81 typedef int     pthread_mutexattr_t;
82 typedef struct mutex pthread_mutex_t;
83
84 /* mutex and condition variable scope - process or system */
85 #define PTHREAD_SHARE_PRIVATE   0
86 #define PTHREAD_SHARE_PROCESS   1
87
88 /* condition variable attributes and condition variable type */
89 typedef int     pthread_condattr_t;
90 typedef struct condition pthread_cond_t;
91
92 LDAP_END_DECL
93
94 #elif defined( HAVE_THR )
95 /**************************************
96  *                                    *
97  * thread definitions for Solaris LWP *
98  *                                    *
99  **************************************/
100
101 #include <thread.h>
102 #include <synch.h>
103
104 LDAP_BEGIN_DECL
105
106 typedef void    *(*VFP)();
107
108 /* default attr states */
109 #define pthread_mutexattr_default       NULL
110 #define pthread_condattr_default        NULL
111
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
121
122
123 #if !defined(__SunOS_5_6)
124 /* thread attributes and thread type */
125 typedef int             pthread_attr_t;
126 typedef thread_t        pthread_t;
127
128 /* mutex attributes and mutex type */
129 typedef int     pthread_mutexattr_t;
130 typedef mutex_t pthread_mutex_t;
131
132 /* condition variable attributes and condition variable type */
133 typedef int     pthread_condattr_t;
134 typedef cond_t  pthread_cond_t;
135 #endif /* ! sunos56 */
136
137 LDAP_END_DECL
138
139 #elif defined( HAVE_LWP )
140 /*************************************
141  *                                   *
142  * thread definitions for SunOS LWP  *
143  *                                   *
144  *************************************/
145
146 #include <lwp/lwp.h>
147 #include <lwp/stackdep.h>
148
149 LDAP_BEGIN_DECL
150
151 typedef void    *(*VFP)();
152
153 /* thread attributes and thread type */
154 typedef int             pthread_attr_t;
155 typedef thread_t        pthread_t;
156
157 /* default attr states */
158 #define pthread_mutexattr_default       NULL
159 #define pthread_condattr_default        NULL
160
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
167
168 /* mutex attributes and mutex type */
169 typedef int     pthread_mutexattr_t;
170 typedef mon_t   pthread_mutex_t;
171
172 /* mutex and condition variable scope - process or system */
173 #define PTHREAD_SHARE_PRIVATE   0
174 #define PTHREAD_SHARE_PROCESS   1
175
176 /* condition variable attributes and condition variable type */
177 typedef int     pthread_condattr_t;
178 typedef struct lwpcv {
179         int             lcv_created;
180         cv_t            lcv_cv;
181 } pthread_cond_t;
182
183 LDAP_END_DECL
184
185 #else
186
187 /***********************************
188  *                                 *
189  * thread definitions for no       *
190  * underlying library support      *
191  *                                 *
192  ***********************************/
193
194 LDAP_BEGIN_DECL
195
196 #ifndef NO_THREADS
197 #define NO_THREADS 1
198 #endif
199
200 #ifndef PREEMPTIVE_THREADS
201 /* treat no threads as preemptive */
202 #define PREEMPTIVE_THREADS 1
203 #endif
204
205 typedef void    *(*VFP)();
206
207 /* thread attributes and thread type */
208 typedef int     pthread_attr_t;
209 typedef int     pthread_t;
210
211 /* default attr states */
212 #define pthread_mutexattr_default       NULL
213 #define pthread_condattr_default        NULL
214
215 /* thread state - joinable or not */
216 #define PTHREAD_CREATE_JOINABLE 0
217 #define PTHREAD_CREATE_DETACHED 0
218 /* thread scope - who is in scheduling pool */
219 #define PTHREAD_SCOPE_PROCESS   0
220 #define PTHREAD_SCOPE_SYSTEM    0
221
222 /* mutex attributes and mutex type */
223 typedef int     pthread_mutexattr_t;
224 typedef int     pthread_mutex_t;
225
226 /* mutex and condition variable scope - process or system */
227 #define PTHREAD_SHARE_PRIVATE   0
228 #define PTHREAD_SHARE_PROCESS   0
229
230 /* condition variable attributes and condition variable type */
231 typedef int     pthread_condattr_t;
232 typedef int     pthread_cond_t;
233
234 LDAP_END_DECL
235
236 #endif /* no threads support */
237 #endif /* _LTHREAD_H */