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 #if defined( HAVE_PTHREADS )
17 /**********************************
19 * definitions for POSIX Threads *
21 **********************************/
30 typedef pthread_t ldap_int_thread_t;
31 typedef pthread_mutex_t ldap_int_thread_mutex_t;
32 typedef pthread_cond_t ldap_int_thread_cond_t;
34 #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
35 defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
36 defined( _POSIX_THREADSAFE_FUNCTIONS )
37 #define HAVE_REENTRANT_FUNCTIONS 1
40 #if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
41 defined( HAVE_THR_GETCONCURRENCY )
42 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
45 #if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
46 defined( HAVE_THR_SETCONCURRENCY )
47 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
50 #if 0 && defined( HAVE_PTHREAD_RWLOCK_DESTROY )
51 #define LDAP_THREAD_HAVE_RDWR 1
52 typedef pthread_rwlock_t ldap_pvt_thread_rdwr_t;
57 #elif defined ( HAVE_MACH_CTHREADS )
58 /**********************************
60 * definitions for Mach CThreads *
62 **********************************/
64 #include <mach/cthreads.h>
68 typedef cthread_t ldap_int_thread_t;
69 typedef struct mutex ldap_int_thread_mutex_t;
70 typedef struct condition ldap_int_thread_cond_t;
74 #elif defined( HAVE_GNU_PTH )
75 /***********************************
77 * thread definitions for GNU Pth *
79 ***********************************/
81 #define PTH_SYSCALL_SOFT 1
86 typedef pth_t ldap_int_thread_t;
87 typedef pth_mutex_t ldap_int_thread_mutex_t;
88 typedef pth_cond_t ldap_int_thread_cond_t;
91 #define LDAP_THREAD_HAVE_RDWR 1
92 typedef pth_rwlock_t ldap_pvt_thread_rdwr_t;
97 #elif defined( HAVE_THR )
98 /********************************************
100 * thread definitions for Solaris LWP (THR) *
102 ********************************************/
109 typedef thread_t ldap_int_thread_t;
110 typedef mutex_t ldap_int_thread_mutex_t;
111 typedef cond_t ldap_int_thread_cond_t;
113 #define HAVE_REENTRANT_FUNCTIONS 1
115 #ifdef HAVE_THR_GETCONCURRENCY
116 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
118 #ifdef HAVE_THR_SETCONCURRENCY
119 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
124 #elif defined( HAVE_LWP )
125 /*************************************
127 * thread definitions for SunOS LWP *
129 *************************************/
132 #include <lwp/stackdep.h>
133 #define LDAP_THREAD_HAVE_SLEEP 1
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;
181 #define LDAP_THREAD_HAVE_TPOOL 1
182 typedef int ldap_int_thread_pool_t;
186 #endif /* no threads support */
190 LDAP_F(int) ldap_int_thread_initialize LDAP_P(( void ));
191 LDAP_F(int) ldap_int_thread_destroy LDAP_P(( void ));
192 LDAP_F(int) ldap_int_thread_pool_startup ( void );
193 LDAP_F(int) ldap_int_thread_pool_shutdown ( void );
195 #ifndef LDAP_THREAD_HAVE_TPOOL
196 typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
201 #endif /* _LDAP_INT_THREAD_H */