3 * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
11 /* ldap_int_thread.h - ldap internal thread wrappers header file */
13 #ifndef _LDAP_INT_THREAD_H
14 #define _LDAP_INT_THREAD_H
16 #include "ldap_cdefs.h"
18 #if defined( HAVE_PTHREADS )
19 /**********************************
21 * definitions for POSIX Threads *
23 **********************************/
32 typedef pthread_t ldap_int_thread_t;
33 typedef pthread_mutex_t ldap_int_thread_mutex_t;
34 typedef pthread_cond_t ldap_int_thread_cond_t;
36 #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
37 defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
38 defined( _POSIX_THREADSAFE_FUNCTIONS )
39 #define HAVE_REENTRANT_FUNCTIONS 1
42 #if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
43 defined( HAVE_THR_GETCONCURRENCY )
44 #define HAVE_GETCONCURRENCY 1
47 #if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
48 defined( HAVE_THR_SETCONCURRENCY )
49 #define HAVE_SETCONCURRENCY 1
52 #if defined( HAVE_PTHREAD_RWLOCK_DESTROY )
53 #define LDAP_THREAD_HAVE_RDWR 1
54 typedef pthread_rwlock_t ldap_pvt_thread_rdwr_t;
59 #elif defined ( HAVE_MACH_CTHREADS )
60 /**********************************
62 * definitions for Mach CThreads *
64 **********************************/
66 #include <mach/cthreads.h>
70 typedef cthread_t ldap_int_thread_t;
71 typedef struct mutex ldap_int_thread_mutex_t;
72 typedef struct condition ldap_int_thread_cond_t;
76 #elif defined( HAVE_GNU_PTH )
77 /***********************************
79 * thread definitions for GNU Pth *
81 ***********************************/
83 #define PTH_SYSCALL_SOFT 1
88 typedef pth_t ldap_int_thread_t;
89 typedef pth_mutex_t ldap_int_thread_mutex_t;
90 typedef pth_cond_t ldap_int_thread_cond_t;
92 #define LDAP_THREAD_HAVE_RDWR 1
93 typedef pth_rwlock_t ldap_pvt_thread_rdwr_t;
98 #elif defined( HAVE_THR )
99 /********************************************
101 * thread definitions for Solaris LWP (THR) *
103 ********************************************/
110 typedef thread_t ldap_int_thread_t;
111 typedef mutex_t ldap_int_thread_mutex_t;
112 typedef cond_t ldap_int_thread_cond_t;
114 #define HAVE_REENTRANT_FUNCTIONS 1
116 #ifdef HAVE_THR_GETCONCURRENCY
117 #define HAVE_GETCONCURRENCY 1
119 #ifdef HAVE_THR_SETCONCURRENCY
120 #define HAVE_SETCONCURRENCY 1
125 #elif defined( HAVE_LWP )
126 /*************************************
128 * thread definitions for SunOS LWP *
130 *************************************/
133 #include <lwp/stackdep.h>
137 typedef thread_t ldap_int_thread_t;
138 typedef mon_t ldap_int_thread_mutex_t;
139 struct ldap_int_thread_lwp_cv {
143 typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
145 #define HAVE_REENTRANT_FUNCTIONS 1
149 #elif defined(HAVE_NT_THREADS)
156 typedef unsigned long ldap_int_thread_t;
157 typedef HANDLE ldap_int_thread_mutex_t;
158 typedef HANDLE ldap_int_thread_cond_t;
164 /***********************************
166 * thread definitions for no *
167 * underlying library support *
169 ***********************************/
177 typedef int ldap_int_thread_t;
178 typedef int ldap_int_thread_mutex_t;
179 typedef int ldap_int_thread_cond_t;
183 #endif /* no threads support */
188 ldap_int_thread_initialize LDAP_P(( void ));
191 ldap_int_thread_destroy LDAP_P(( void ));
193 LIBLDAP_F( unsigned int )
194 ldap_int_thread_sleep LDAP_P(( unsigned int s ));
196 #ifdef HAVE_GETCONCURRENCY
198 ldap_int_thread_get_concurrency LDAP_P(( void ));
201 #ifdef HAVE_SETCONCURRENCY
202 # ifndef LDAP_THREAD_CONCURRENCY
203 /* three concurrent threads should be enough */
204 # define LDAP_THREAD_CONCURRENCY 3
207 ldap_int_thread_set_concurrency LDAP_P(( int ));
211 ldap_int_thread_create LDAP_P((
212 ldap_int_thread_t * thread,
214 void *(*start_routine)( void * ),
218 ldap_int_thread_exit LDAP_P(( void *retval ));
221 ldap_int_thread_join LDAP_P(( ldap_int_thread_t thread, void **status ));
224 ldap_int_thread_kill LDAP_P(( ldap_int_thread_t thread, int signo ));
227 ldap_int_thread_yield LDAP_P(( void ));
230 ldap_int_thread_cond_init LDAP_P(( ldap_int_thread_cond_t *cond ));
233 ldap_int_thread_cond_destroy LDAP_P(( ldap_int_thread_cond_t *cond ));
236 ldap_int_thread_cond_signal LDAP_P(( ldap_int_thread_cond_t *cond ));
239 ldap_int_thread_cond_broadcast LDAP_P(( ldap_int_thread_cond_t *cond ));
242 ldap_int_thread_cond_wait LDAP_P((
243 ldap_int_thread_cond_t *cond,
244 ldap_int_thread_mutex_t *mutex ));
247 ldap_int_thread_mutex_init LDAP_P(( ldap_int_thread_mutex_t *mutex ));
250 ldap_int_thread_mutex_destroy LDAP_P(( ldap_int_thread_mutex_t *mutex ));
253 ldap_int_thread_mutex_lock LDAP_P(( ldap_int_thread_mutex_t *mutex ));
256 ldap_int_thread_mutex_trylock LDAP_P(( ldap_int_thread_mutex_t *mutex ));
259 ldap_int_thread_mutex_unlock LDAP_P(( ldap_int_thread_mutex_t *mutex ));
263 #endif /* _LDAP_INT_THREAD_H */