1 /* ldap_int_thread.h - ldap internal thread wrappers header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 #ifndef _LDAP_INT_THREAD_H
18 #define _LDAP_INT_THREAD_H
20 #if defined( HAVE_PTHREADS )
21 /**********************************
23 * definitions for POSIX Threads *
25 **********************************/
34 typedef pthread_t ldap_int_thread_t;
35 typedef pthread_mutex_t ldap_int_thread_mutex_t;
36 typedef pthread_cond_t ldap_int_thread_cond_t;
38 #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
39 defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
40 defined( _POSIX_THREADSAFE_FUNCTIONS )
41 #define HAVE_REENTRANT_FUNCTIONS 1
44 #if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
45 defined( HAVE_THR_GETCONCURRENCY )
46 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
49 #if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
50 defined( HAVE_THR_SETCONCURRENCY )
51 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
54 #if 0 && defined( HAVE_PTHREAD_RWLOCK_DESTROY )
55 #define LDAP_THREAD_HAVE_RDWR 1
56 typedef pthread_rwlock_t ldap_pvt_thread_rdwr_t;
61 #elif defined ( HAVE_MACH_CTHREADS )
62 /**********************************
64 * definitions for Mach CThreads *
66 **********************************/
68 #if defined( HAVE_MACH_CTHREADS_H )
69 # include <mach/cthreads.h>
70 #elif defined( HAVE_CTHREAD_H
71 # include <cthreads.h>
76 typedef cthread_t ldap_int_thread_t;
77 typedef struct mutex ldap_int_thread_mutex_t;
78 typedef struct condition ldap_int_thread_cond_t;
82 #elif defined( HAVE_GNU_PTH )
83 /***********************************
85 * thread definitions for GNU Pth *
87 ***********************************/
89 #define PTH_SYSCALL_SOFT 1
94 typedef pth_t ldap_int_thread_t;
95 typedef pth_mutex_t ldap_int_thread_mutex_t;
96 typedef pth_cond_t ldap_int_thread_cond_t;
99 #define LDAP_THREAD_HAVE_RDWR 1
100 typedef pth_rwlock_t ldap_pvt_thread_rdwr_t;
105 #elif defined( HAVE_THR )
106 /********************************************
108 * thread definitions for Solaris LWP (THR) *
110 ********************************************/
117 typedef thread_t ldap_int_thread_t;
118 typedef mutex_t ldap_int_thread_mutex_t;
119 typedef cond_t ldap_int_thread_cond_t;
121 #define HAVE_REENTRANT_FUNCTIONS 1
123 #ifdef HAVE_THR_GETCONCURRENCY
124 #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
126 #ifdef HAVE_THR_SETCONCURRENCY
127 #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
132 #elif defined( HAVE_LWP )
133 /*************************************
135 * thread definitions for SunOS LWP *
137 *************************************/
140 #include <lwp/stackdep.h>
141 #define LDAP_THREAD_HAVE_SLEEP 1
145 typedef thread_t ldap_int_thread_t;
146 typedef mon_t ldap_int_thread_mutex_t;
147 struct ldap_int_thread_lwp_cv {
151 typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
153 #define HAVE_REENTRANT_FUNCTIONS 1
157 #elif defined(HAVE_NT_THREADS)
164 typedef unsigned long ldap_int_thread_t;
165 typedef HANDLE ldap_int_thread_mutex_t;
166 typedef HANDLE ldap_int_thread_cond_t;
172 /***********************************
174 * thread definitions for no *
175 * underlying library support *
177 ***********************************/
185 typedef int ldap_int_thread_t;
186 typedef int ldap_int_thread_mutex_t;
187 typedef int ldap_int_thread_cond_t;
189 #define LDAP_THREAD_HAVE_TPOOL 1
190 typedef int ldap_int_thread_pool_t;
194 #endif /* no threads support */
198 LDAP_F(int) ldap_int_thread_initialize LDAP_P(( void ));
199 LDAP_F(int) ldap_int_thread_destroy LDAP_P(( void ));
200 LDAP_F(int) ldap_int_thread_pool_startup ( void );
201 LDAP_F(int) ldap_int_thread_pool_shutdown ( void );
203 #ifndef LDAP_THREAD_HAVE_TPOOL
204 typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
209 #endif /* _LDAP_INT_THREAD_H */