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
54 #elif defined ( HAVE_MACH_CTHREADS )
55 /**********************************
57 * definitions for Mach CThreads *
59 **********************************/
61 #include <mach/cthreads.h>
65 typedef cthread_t ldap_int_thread_t;
66 typedef struct mutex ldap_int_thread_mutex_t;
67 typedef struct condition ldap_int_thread_cond_t;
71 #elif defined( HAVE_GNU_PTH )
72 /***********************************
74 * thread definitions for GNU Pth *
76 ***********************************/
78 #define PTH_SYSCALL_SOFT 1
83 typedef pth_t ldap_int_thread_t;
84 typedef pth_mutex_t ldap_int_thread_mutex_t;
85 typedef pth_cond_t ldap_int_thread_cond_t;
90 #elif defined( HAVE_THR )
91 /********************************************
93 * thread definitions for Solaris LWP (THR) *
95 ********************************************/
102 typedef thread_t ldap_int_thread_t;
103 typedef mutex_t ldap_int_thread_mutex_t;
104 typedef cond_t ldap_int_thread_cond_t;
106 #define HAVE_REENTRANT_FUNCTIONS 1
108 #ifdef HAVE_THR_GETCONCURRENCY
109 #define HAVE_GETCONCURRENCY 1
111 #ifdef HAVE_THR_SETCONCURRENCY
112 #define HAVE_SETCONCURRENCY 1
117 #elif defined( HAVE_LWP )
118 /*************************************
120 * thread definitions for SunOS LWP *
122 *************************************/
125 #include <lwp/stackdep.h>
129 typedef thread_t ldap_int_thread_t;
130 typedef mon_t ldap_int_thread_mutex_t;
131 struct ldap_int_thread_lwp_cv {
135 typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
137 #define HAVE_REENTRANT_FUNCTIONS 1
141 #elif defined(HAVE_NT_THREADS)
148 typedef unsigned long ldap_int_thread_t;
149 typedef HANDLE ldap_int_thread_mutex_t;
150 typedef HANDLE ldap_int_thread_cond_t;
156 /***********************************
158 * thread definitions for no *
159 * underlying library support *
161 ***********************************/
169 typedef int ldap_int_thread_t;
170 typedef int ldap_int_thread_mutex_t;
171 typedef int ldap_int_thread_cond_t;
175 #endif /* no threads support */
180 ldap_int_thread_initialize LDAP_P(( void ));
183 ldap_int_thread_destroy LDAP_P(( void ));
185 LIBLDAP_F( unsigned int )
186 ldap_int_thread_sleep LDAP_P(( unsigned int s ));
188 #ifdef HAVE_GETCONCURRENCY
190 ldap_int_thread_get_concurrency LDAP_P(( void ));
193 #ifdef HAVE_SETCONCURRENCY
194 # ifndef LDAP_THREAD_CONCURRENCY
195 /* three concurrent threads should be enough */
196 # define LDAP_THREAD_CONCURRENCY 3
199 ldap_int_thread_set_concurrency LDAP_P(( int ));
203 ldap_int_thread_create LDAP_P((
204 ldap_int_thread_t * thread,
206 void *(*start_routine)( void * ),
210 ldap_int_thread_exit LDAP_P(( void *retval ));
213 ldap_int_thread_join LDAP_P(( ldap_int_thread_t thread, void **status ));
216 ldap_int_thread_kill LDAP_P(( ldap_int_thread_t thread, int signo ));
219 ldap_int_thread_yield LDAP_P(( void ));
222 ldap_int_thread_cond_init LDAP_P(( ldap_int_thread_cond_t *cond ));
225 ldap_int_thread_cond_destroy LDAP_P(( ldap_int_thread_cond_t *cond ));
228 ldap_int_thread_cond_signal LDAP_P(( ldap_int_thread_cond_t *cond ));
231 ldap_int_thread_cond_broadcast LDAP_P(( ldap_int_thread_cond_t *cond ));
234 ldap_int_thread_cond_wait LDAP_P((
235 ldap_int_thread_cond_t *cond,
236 ldap_int_thread_mutex_t *mutex ));
239 ldap_int_thread_mutex_init LDAP_P(( ldap_int_thread_mutex_t *mutex ));
242 ldap_int_thread_mutex_destroy LDAP_P(( ldap_int_thread_mutex_t *mutex ));
245 ldap_int_thread_mutex_lock LDAP_P(( ldap_int_thread_mutex_t *mutex ));
248 ldap_int_thread_mutex_trylock LDAP_P(( ldap_int_thread_mutex_t *mutex ));
251 ldap_int_thread_mutex_unlock LDAP_P(( ldap_int_thread_mutex_t *mutex ));
255 #endif /* _LDAP_INT_THREAD_H */