]> git.sur5r.net Git - openldap/blob - include/lthread.h
Import op -> slap_op , conn -> slap_conn change from rel eng 1.1.
[openldap] / include / lthread.h
1 /*
2  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted only
6  * as authorized by the OpenLDAP Public License.  A copy of this
7  * license is available at http://www.OpenLDAP.org/license.html or
8  * in file LICENSE in the top-level directory of the distribution.
9  */
10 /* lthread.h - ldap threads header file */
11
12 #ifndef _LTHREAD_H
13 #define _LTHREAD_H
14
15 #include "portable.h"
16
17 #if defined( HAVE_PTHREADS )
18 /**********************************
19  *                                *
20  * definitions for POSIX Threads  *
21  *                                *
22  **********************************/
23
24 #include <pthread.h>
25 #ifdef HAVE_SCHED_H
26 #include <sched.h>
27 #endif
28
29 LDAP_BEGIN_DECL
30
31 #if !defined( HAVE_PTHREAD_ATTR_INIT ) && \
32         defined( HAVE_PTHREAD_ATTR_CREATE )
33 #define pthread_attr_init( a )          pthread_attr_create( a )
34 #endif
35
36 #if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \
37         defined( HAVE_PTHREAD_ATTR_DELETE )
38 #define pthread_attr_destroy( a )       pthread_attr_delete( a )
39 #endif
40
41 #if !defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) && \
42         defined( HAVE_PTHREAD_ATTR_SETDETACH_NP )
43 #define pthread_attr_setdetachstate( a, b ) \
44                                         pthread_attr_setdetach_np( a, b )
45 #endif
46
47 #ifndef HAVE_PTHREAD_KILL
48 /* missing pthread_kill(), define prototype */
49 LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig ));
50 #endif
51
52 #ifndef HAVE_PTHREADS_D4
53 #define pthread_mutexattr_default       NULL
54 #define pthread_condattr_default        NULL
55
56 #ifdef HAVE_SCHED_YIELD
57 #define pthread_yield sched_yield
58 #endif
59 #endif
60
61 LDAP_END_DECL
62
63 #elif defined ( HAVE_MACH_CTHREADS )
64 /**********************************
65  *                                *
66  * definitions for Mach CThreads  *
67  *                                *
68  **********************************/
69
70 #include <mach/cthreads.h>
71
72 LDAP_BEGIN_DECL
73
74 typedef cthread_fn_t    VFP;
75 typedef int             pthread_attr_t;
76 typedef cthread_t       pthread_t;
77
78 /* default attr states */
79 #define pthread_mutexattr_default       NULL
80 #define pthread_condattr_default        NULL
81
82 /* thread state - joinable or not */
83 #define PTHREAD_CREATE_JOINABLE 0
84 #define PTHREAD_CREATE_DETACHED 1
85 /* thread scope - who is in scheduling pool */
86 #define PTHREAD_SCOPE_PROCESS   0
87 #define PTHREAD_SCOPE_SYSTEM    1
88
89 /* mutex attributes and mutex type */
90 typedef int     pthread_mutexattr_t;
91 typedef struct mutex pthread_mutex_t;
92
93 /* mutex and condition variable scope - process or system */
94 #define PTHREAD_SHARE_PRIVATE   0
95 #define PTHREAD_SHARE_PROCESS   1
96
97 /* condition variable attributes and condition variable type */
98 typedef int     pthread_condattr_t;
99 typedef struct condition pthread_cond_t;
100
101 LDAP_END_DECL
102
103 #elif defined( HAVE_THR )
104 /**************************************
105  *                                    *
106  * thread definitions for Solaris LWP *
107  *                                    *
108  **************************************/
109
110 #include <thread.h>
111 #include <synch.h>
112
113 LDAP_BEGIN_DECL
114
115 typedef void    *(*VFP)();
116
117 /* default attr states */
118 #define pthread_mutexattr_default       NULL
119 #define pthread_condattr_default        NULL
120
121 /* thread state - joinable or not */
122 #define PTHREAD_CREATE_JOINABLE 0
123 #define PTHREAD_CREATE_DETACHED THR_DETACHED
124 /* thread scope - who is in scheduling pool */
125 #define PTHREAD_SCOPE_PROCESS   0
126 #define PTHREAD_SCOPE_SYSTEM    THR_BOUND
127 /* mutex and condition variable scope - process or system */
128 #define PTHREAD_SHARE_PRIVATE   USYNC_THREAD
129 #define PTHREAD_SHARE_PROCESS   USYNC_PROCESS
130
131 /* thread attributes and thread type */
132 typedef int             pthread_attr_t;
133 typedef thread_t        pthread_t;
134
135 /* mutex attributes and mutex type */
136 typedef int     pthread_mutexattr_t;
137 typedef mutex_t pthread_mutex_t;
138
139 /* condition variable attributes and condition variable type */
140 typedef int     pthread_condattr_t;
141 typedef cond_t  pthread_cond_t;
142
143 LDAP_END_DECL
144
145 #elif defined( HAVE_LWP )
146 /*************************************
147  *                                   *
148  * thread definitions for SunOS LWP  *
149  *                                   *
150  *************************************/
151
152 #include <lwp/lwp.h>
153 #include <lwp/stackdep.h>
154
155 LDAP_BEGIN_DECL
156
157 stkalign_t *get_stack( int *stacknop );
158 void free_stack( int *stackno );
159
160 typedef void    *(*VFP)();
161
162 /* thread attributes and thread type */
163 typedef int             pthread_attr_t;
164 typedef thread_t        pthread_t;
165
166 /* default attr states */
167 #define pthread_mutexattr_default       NULL
168 #define pthread_condattr_default        NULL
169
170 /* thread state - joinable or not */
171 #define PTHREAD_CREATE_JOINABLE 0
172 #define PTHREAD_CREATE_DETACHED 1
173 /* thread scope - who is in scheduling pool */
174 #define PTHREAD_SCOPE_PROCESS   0
175 #define PTHREAD_SCOPE_SYSTEM    1
176
177 /* mutex attributes and mutex type */
178 typedef int     pthread_mutexattr_t;
179 typedef mon_t   pthread_mutex_t;
180
181 /* mutex and condition variable scope - process or system */
182 #define PTHREAD_SHARE_PRIVATE   0
183 #define PTHREAD_SHARE_PROCESS   1
184
185 /* condition variable attributes and condition variable type */
186 typedef int     pthread_condattr_t;
187 typedef struct lwpcv {
188         int             lcv_created;
189         cv_t            lcv_cv;
190 } pthread_cond_t;
191
192 LDAP_END_DECL
193
194 #else
195
196 /***********************************
197  *                                 *
198  * thread definitions for no       *
199  * underlying library support      *
200  *                                 *
201  ***********************************/
202
203 LDAP_BEGIN_DECL
204
205 #ifndef NO_THREADS
206 #define NO_THREADS 1
207 #endif
208
209 typedef void    *(*VFP)();
210
211 /* thread attributes and thread type */
212 typedef int     pthread_attr_t;
213 typedef int     pthread_t;
214
215 /* default attr states */
216 #define pthread_mutexattr_default       NULL
217 #define pthread_condattr_default        NULL
218
219 /* thread state - joinable or not */
220 #define PTHREAD_CREATE_JOINABLE 0
221 #define PTHREAD_CREATE_DETACHED 0
222 /* thread scope - who is in scheduling pool */
223 #define PTHREAD_SCOPE_PROCESS   0
224 #define PTHREAD_SCOPE_SYSTEM    0
225
226 /* mutex attributes and mutex type */
227 typedef int     pthread_mutexattr_t;
228 typedef int     pthread_mutex_t;
229
230 /* mutex and condition variable scope - process or system */
231 #define PTHREAD_SHARE_PRIVATE   0
232 #define PTHREAD_SHARE_PROCESS   0
233
234 /* condition variable attributes and condition variable type */
235 typedef int     pthread_condattr_t;
236 typedef int     pthread_cond_t;
237
238 LDAP_END_DECL
239
240 #endif /* no threads support */
241 #endif /* _LTHREAD_H */