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