3 * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
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.
12 /* ldap_int_thread.h - ldap internal thread wrappers header file */
14 #ifndef _LDAP_INT_THREAD_H
15 #define _LDAP_INT_THREAD_H
17 #if defined( HAVE_PTHREADS )
18 /**********************************
20 * definitions for POSIX Threads *
22 **********************************/
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;
35 #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
36 defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
37 defined( _POSIX_THREADSAFE_FUNCTIONS )
38 #define HAVE_REENTRANT_FUNCTIONS 1
41 #if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
42 defined( HAVE_THR_GETCONCURRENCY )
43 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
46 #if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
47 defined( HAVE_THR_SETCONCURRENCY )
48 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
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;
58 #elif defined ( HAVE_MACH_CTHREADS )
59 /**********************************
61 * definitions for Mach CThreads *
63 **********************************/
65 #if defined( HAVE_MACH_CTHREADS_H )
66 # include <mach/cthreads.h>
67 #elif defined( HAVE_CTHREAD_H
68 # include <cthreads.h>
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;
79 #elif defined( HAVE_GNU_PTH )
80 /***********************************
82 * thread definitions for GNU Pth *
84 ***********************************/
86 #define PTH_SYSCALL_SOFT 1
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;
96 #define LDAP_THREAD_HAVE_RDWR 1
97 typedef pth_rwlock_t ldap_pvt_thread_rdwr_t;
102 #elif defined( HAVE_THR )
103 /********************************************
105 * thread definitions for Solaris LWP (THR) *
107 ********************************************/
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;
118 #define HAVE_REENTRANT_FUNCTIONS 1
120 #ifdef HAVE_THR_GETCONCURRENCY
121 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
123 #ifdef HAVE_THR_SETCONCURRENCY
124 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
129 #elif defined( HAVE_LWP )
130 /*************************************
132 * thread definitions for SunOS LWP *
134 *************************************/
137 #include <lwp/stackdep.h>
138 #define LDAP_THREAD_HAVE_SLEEP 1
142 typedef thread_t ldap_int_thread_t;
143 typedef mon_t ldap_int_thread_mutex_t;
144 struct ldap_int_thread_lwp_cv {
148 typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
150 #define HAVE_REENTRANT_FUNCTIONS 1
154 #elif defined(HAVE_NT_THREADS)
161 typedef unsigned long ldap_int_thread_t;
162 typedef HANDLE ldap_int_thread_mutex_t;
163 typedef HANDLE ldap_int_thread_cond_t;
169 /***********************************
171 * thread definitions for no *
172 * underlying library support *
174 ***********************************/
182 typedef int ldap_int_thread_t;
183 typedef int ldap_int_thread_mutex_t;
184 typedef int ldap_int_thread_cond_t;
186 #define LDAP_THREAD_HAVE_TPOOL 1
187 typedef int ldap_int_thread_pool_t;
191 #endif /* no threads support */
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 );
200 #ifndef LDAP_THREAD_HAVE_TPOOL
201 typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
206 #endif /* _LDAP_INT_THREAD_H */