]> git.sur5r.net Git - openldap/blob - include/lthread.h
VC++ Port: round 1
[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 LDAP_BEGIN_DECL
9
10 #if defined ( THREAD_NEXT_CTHREADS )
11
12 #define _THREAD
13
14 #include <mach/cthreads.h>
15
16 typedef cthread_fn_t    VFP;
17 typedef int             pthread_attr_t;
18 typedef cthread_t       pthread_t;
19
20 /* default attr states */
21 #define pthread_mutexattr_default       NULL
22 #define pthread_condattr_default        NULL
23
24 /* thread state - joinable or not */
25 #define PTHREAD_CREATE_JOINABLE 0
26 #define PTHREAD_CREATE_DETACHED 1
27 /* thread scope - who is in scheduling pool */
28 #define PTHREAD_SCOPE_PROCESS   0
29 #define PTHREAD_SCOPE_SYSTEM    1
30
31 /* mutex attributes and mutex type */
32 typedef int     pthread_mutexattr_t;
33 typedef struct mutex pthread_mutex_t;
34
35 /* mutex and condition variable scope - process or system */
36 #define PTHREAD_SHARE_PRIVATE   0
37 #define PTHREAD_SHARE_PROCESS   1
38
39 /* condition variable attributes and condition variable type */
40 typedef int     pthread_condattr_t;
41 typedef struct condition pthread_cond_t;
42
43 #elif defined( THREAD_SUNOS4_LWP )
44 /***********************************
45  *                                 *
46  * thread definitions for sunos4   *
47  *                                 *
48  ***********************************/
49
50 #define _THREAD
51
52 #include <lwp/lwp.h>
53 #include <lwp/stackdep.h>
54
55 typedef void    *(*VFP)();
56
57 /* thread attributes and thread type */
58 typedef int             pthread_attr_t;
59 typedef thread_t        pthread_t;
60
61 /* default attr states */
62 #define pthread_mutexattr_default       NULL
63 #define pthread_condattr_default        NULL
64
65 /* thread state - joinable or not */
66 #define PTHREAD_CREATE_JOINABLE 0
67 #define PTHREAD_CREATE_DETACHED 1
68 /* thread scope - who is in scheduling pool */
69 #define PTHREAD_SCOPE_PROCESS   0
70 #define PTHREAD_SCOPE_SYSTEM    1
71
72 /* mutex attributes and mutex type */
73 typedef int     pthread_mutexattr_t;
74 typedef mon_t   pthread_mutex_t;
75
76 /* mutex and condition variable scope - process or system */
77 #define PTHREAD_SHARE_PRIVATE   0
78 #define PTHREAD_SHARE_PROCESS   1
79
80 /* condition variable attributes and condition variable type */
81 typedef int     pthread_condattr_t;
82 typedef struct lwpcv {
83         int             lcv_created;
84         cv_t            lcv_cv;
85 } pthread_cond_t;
86
87 #else /* end sunos4 */
88
89 #if defined( THREAD_SUNOS5_LWP )
90 /***********************************
91  *                                 *
92  * thread definitions for sunos5   *
93  *                                 *
94  ***********************************/
95
96 #define _THREAD
97
98 #include <thread.h>
99 #include <synch.h>
100
101 typedef void    *(*VFP)();
102
103 /* sunos5 threads are preemptive */
104 #define PTHREAD_PREEMPTIVE      1
105
106 #if !defined(__SunOS_5_6)
107 /* thread attributes and thread type */
108 typedef int             pthread_attr_t;
109 typedef thread_t        pthread_t;
110 #endif /* ! sunos56 */
111
112 /* default attr states */
113 #define pthread_mutexattr_default       NULL
114 #define pthread_condattr_default        NULL
115
116 /* thread state - joinable or not */
117 #define PTHREAD_CREATE_JOINABLE 0
118 #define PTHREAD_CREATE_DETACHED THR_DETACHED
119 /* thread scope - who is in scheduling pool */
120 #define PTHREAD_SCOPE_PROCESS   0
121 #define PTHREAD_SCOPE_SYSTEM    THR_BOUND
122
123 #if !defined(__SunOS_5_6)
124 /* mutex attributes and mutex type */
125 typedef int     pthread_mutexattr_t;
126 typedef mutex_t pthread_mutex_t;
127 #endif /* ! sunos56 */
128
129 /* mutex and condition variable scope - process or system */
130 #define PTHREAD_SHARE_PRIVATE   USYNC_THREAD
131 #define PTHREAD_SHARE_PROCESS   USYNC_PROCESS
132
133 #if !defined(__SunOS_5_6)
134 /* condition variable attributes and condition variable type */
135 typedef int     pthread_condattr_t;
136 typedef cond_t  pthread_cond_t;
137 #endif /* ! sunos56 */
138
139 #else /* end sunos5 */
140
141 #if defined( THREAD_MIT_PTHREADS )
142 /***********************************
143  *                                 *
144  * definitions for mit pthreads    *
145  *                                 *
146  ***********************************/
147
148 #define _THREAD
149
150 #include <pthread.h>
151
152 #else /* end mit pthreads */
153
154 #if defined( THREAD_DCE_PTHREADS )
155 /***********************************
156  *                                 *
157  * definitions for mit pthreads    *
158  *                                 *
159  ***********************************/
160
161 #define _THREAD
162
163 #include <pthread.h>
164
165 /* dce threads are preemptive */
166 #define PTHREAD_PREEMPTIVE      1
167
168 #define pthread_attr_init( a )          pthread_attr_create( a )
169 #define pthread_attr_destroy( a )       pthread_attr_delete( a )
170 #define pthread_attr_setdetachstate( a, b ) \
171                                         pthread_attr_setdetach_np( a, b )
172
173 #else /* end dce pthreads */
174
175 #if defined( POSIX_THREADS )
176
177 #define _THREAD
178
179 #include <pthread.h>
180
181 #define pthread_mutexattr_default       NULL
182 #define pthread_condattr_default        NULL
183
184 #endif /* posix threads */
185 #endif /* dce pthreads */
186 #endif /* mit pthreads */
187 #endif /* sunos5 */
188 #endif /* sunos4 */
189
190 #ifndef _THREAD
191
192 /***********************************
193  *                                 *
194  * thread definitions for no       *
195  * underlying library support      *
196  *                                 *
197  ***********************************/
198
199 typedef void    *(*VFP)();
200
201 /* thread attributes and thread type */
202 typedef int     pthread_attr_t;
203 typedef int     pthread_t;
204
205 /* default attr states */
206 #define pthread_mutexattr_default       NULL
207 #define pthread_condattr_default        NULL
208
209 /* thread state - joinable or not */
210 #define PTHREAD_CREATE_JOINABLE 0
211 #define PTHREAD_CREATE_DETACHED 0
212 /* thread scope - who is in scheduling pool */
213 #define PTHREAD_SCOPE_PROCESS   0
214 #define PTHREAD_SCOPE_SYSTEM    0
215
216 /* mutex attributes and mutex type */
217 typedef int     pthread_mutexattr_t;
218 typedef int     pthread_mutex_t;
219
220 /* mutex and condition variable scope - process or system */
221 #define PTHREAD_SHARE_PRIVATE   0
222 #define PTHREAD_SHARE_PROCESS   0
223
224 /* condition variable attributes and condition variable type */
225 typedef int     pthread_condattr_t;
226 typedef int     pthread_cond_t;
227
228 #endif /* no threads support */
229
230 LDAP_END_DECL
231
232 #endif /* _LTHREAD_H */