]> git.sur5r.net Git - openldap/blob - include/ldap_int_thread.h
Assist in cache debugging
[openldap] / include / ldap_int_thread.h
1 /* ldap_int_thread.h - ldap internal thread wrappers header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  * 
5  * Copyright 1998-2004 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #ifndef _LDAP_INT_THREAD_H
18 #define _LDAP_INT_THREAD_H
19
20 #if defined( HAVE_PTHREADS )
21 /**********************************
22  *                                *
23  * definitions for POSIX Threads  *
24  *                                *
25  **********************************/
26
27 #include <pthread.h>
28 #ifdef HAVE_SCHED_H
29 #include <sched.h>
30 #endif
31
32 LDAP_BEGIN_DECL
33
34 typedef pthread_t               ldap_int_thread_t;
35 typedef pthread_mutex_t         ldap_int_thread_mutex_t;
36 typedef pthread_cond_t          ldap_int_thread_cond_t;
37
38 #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
39         defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
40         defined( _POSIX_THREADSAFE_FUNCTIONS )
41 #define HAVE_REENTRANT_FUNCTIONS 1
42 #endif
43
44 #if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
45         defined( HAVE_THR_GETCONCURRENCY )
46 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
47 #endif
48
49 #if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
50         defined( HAVE_THR_SETCONCURRENCY )
51 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
52 #endif
53
54 #if 0 && defined( HAVE_PTHREAD_RWLOCK_DESTROY )
55 #define LDAP_THREAD_HAVE_RDWR 1
56 typedef pthread_rwlock_t ldap_pvt_thread_rdwr_t;
57 #endif
58
59 LDAP_END_DECL
60
61 #elif defined ( HAVE_MACH_CTHREADS )
62 /**********************************
63  *                                *
64  * definitions for Mach CThreads  *
65  *                                *
66  **********************************/
67
68 #if defined( HAVE_MACH_CTHREADS_H )
69 #       include <mach/cthreads.h>
70 #elif defined( HAVE_CTHREAD_H
71 #       include <cthreads.h>
72 #endif
73
74 LDAP_BEGIN_DECL
75
76 typedef cthread_t               ldap_int_thread_t;
77 typedef struct mutex            ldap_int_thread_mutex_t;
78 typedef struct condition        ldap_int_thread_cond_t;
79
80 LDAP_END_DECL
81
82 #elif defined( HAVE_GNU_PTH )
83 /***********************************
84  *                                 *
85  * thread definitions for GNU Pth  *
86  *                                 *
87  ***********************************/
88
89 #define PTH_SYSCALL_SOFT 1
90 #include <pth.h>
91
92 LDAP_BEGIN_DECL
93
94 typedef pth_t           ldap_int_thread_t;
95 typedef pth_mutex_t     ldap_int_thread_mutex_t;
96 typedef pth_cond_t      ldap_int_thread_cond_t;
97
98 #if 0
99 #define LDAP_THREAD_HAVE_RDWR 1
100 typedef pth_rwlock_t ldap_pvt_thread_rdwr_t;
101 #endif
102
103 LDAP_END_DECL
104
105 #elif defined( HAVE_THR )
106 /********************************************
107  *                                          *
108  * thread definitions for Solaris LWP (THR) *
109  *                                          *
110  ********************************************/
111
112 #include <thread.h>
113 #include <synch.h>
114
115 LDAP_BEGIN_DECL
116
117 typedef thread_t                ldap_int_thread_t;
118 typedef mutex_t                 ldap_int_thread_mutex_t;
119 typedef cond_t                  ldap_int_thread_cond_t;
120
121 #define HAVE_REENTRANT_FUNCTIONS 1
122
123 #ifdef HAVE_THR_GETCONCURRENCY
124 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
125 #endif
126 #ifdef HAVE_THR_SETCONCURRENCY
127 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
128 #endif
129
130 LDAP_END_DECL
131
132 #elif defined( HAVE_LWP )
133 /*************************************
134  *                                   *
135  * thread definitions for SunOS LWP  *
136  *                                   *
137  *************************************/
138
139 #include <lwp/lwp.h>
140 #include <lwp/stackdep.h>
141 #define LDAP_THREAD_HAVE_SLEEP 1
142
143 LDAP_BEGIN_DECL
144
145 typedef thread_t                ldap_int_thread_t;
146 typedef mon_t                   ldap_int_thread_mutex_t;
147 struct ldap_int_thread_lwp_cv {
148         int             lcv_created;
149         cv_t            lcv_cv;
150 };
151 typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
152
153 #define HAVE_REENTRANT_FUNCTIONS 1
154
155 LDAP_END_DECL
156
157 #elif defined(HAVE_NT_THREADS)
158
159 #include <process.h>
160 #include <windows.h>
161
162 LDAP_BEGIN_DECL
163
164 typedef unsigned long   ldap_int_thread_t;
165 typedef HANDLE  ldap_int_thread_mutex_t;
166 typedef HANDLE  ldap_int_thread_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 #ifndef NO_THREADS
180 #define NO_THREADS 1
181 #endif
182
183 LDAP_BEGIN_DECL
184
185 typedef int                     ldap_int_thread_t;
186 typedef int                     ldap_int_thread_mutex_t;
187 typedef int                     ldap_int_thread_cond_t;
188
189 #define LDAP_THREAD_HAVE_TPOOL 1
190 typedef int                     ldap_int_thread_pool_t;
191
192 LDAP_END_DECL
193
194 #endif /* no threads support */
195
196 LDAP_BEGIN_DECL
197
198 LDAP_F(int) ldap_int_thread_initialize LDAP_P(( void ));
199 LDAP_F(int) ldap_int_thread_destroy LDAP_P(( void ));
200 LDAP_F(int) ldap_int_thread_pool_startup ( void );
201 LDAP_F(int) ldap_int_thread_pool_shutdown ( void );
202
203 #ifndef LDAP_THREAD_HAVE_TPOOL
204 typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
205 #endif
206
207 LDAP_END_DECL
208
209 #endif /* _LDAP_INT_THREAD_H */