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