3 * Copyright 1998-2001 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 #include <mach/cthreads.h>
69 typedef cthread_t ldap_int_thread_t;
70 typedef struct mutex ldap_int_thread_mutex_t;
71 typedef struct condition ldap_int_thread_cond_t;
75 #elif defined( HAVE_GNU_PTH )
76 /***********************************
78 * thread definitions for GNU Pth *
80 ***********************************/
82 #define PTH_SYSCALL_SOFT 1
87 typedef pth_t ldap_int_thread_t;
88 typedef pth_mutex_t ldap_int_thread_mutex_t;
89 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 LDAP_THREAD_HAVE_GETCONCURRENCY 1
119 #ifdef HAVE_THR_SETCONCURRENCY
120 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
125 #elif defined( HAVE_LWP )
126 /*************************************
128 * thread definitions for SunOS LWP *
130 *************************************/
133 #include <lwp/stackdep.h>
134 #define LDAP_THREAD_HAVE_SLEEP 1
138 typedef thread_t ldap_int_thread_t;
139 typedef mon_t ldap_int_thread_mutex_t;
140 struct ldap_int_thread_lwp_cv {
144 typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
146 #define HAVE_REENTRANT_FUNCTIONS 1
150 #elif defined(HAVE_NT_THREADS)
157 typedef unsigned long ldap_int_thread_t;
158 typedef HANDLE ldap_int_thread_mutex_t;
159 typedef HANDLE ldap_int_thread_cond_t;
165 /***********************************
167 * thread definitions for no *
168 * underlying library support *
170 ***********************************/
178 typedef int ldap_int_thread_t;
179 typedef int ldap_int_thread_mutex_t;
180 typedef int ldap_int_thread_cond_t;
182 #define LDAP_THREAD_HAVE_TPOOL 1
183 typedef int ldap_int_thread_pool_t;
187 #endif /* no threads support */
191 LDAP_F(int) ldap_int_thread_initialize LDAP_P(( void ));
192 LDAP_F(int) ldap_int_thread_destroy LDAP_P(( void ));
193 LDAP_F(int) ldap_int_thread_pool_startup ( void );
194 LDAP_F(int) ldap_int_thread_pool_shutdown ( void );
196 #ifndef LDAP_THREAD_HAVE_TPOOL
197 typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
202 #endif /* _LDAP_INT_THREAD_H */