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