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