home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ldapsdk.zip / include / ldap_int_thread.h < prev    next >
C/C++ Source or Header  |  2001-06-02  |  5KB  |  203 lines

  1. /* $OpenLDAP: pkg/ldap/include/ldap_int_thread.h,v 1.21 2000/05/19 18:47:32 kurt Exp $ */
  2. /*
  3.  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
  4.  * All rights reserved.
  5.  *
  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.
  11.  */
  12. /* ldap_int_thread.h - ldap internal thread wrappers header file */
  13.  
  14. #ifndef _LDAP_INT_THREAD_H
  15. #define _LDAP_INT_THREAD_H
  16.  
  17. #if defined( HAVE_PTHREADS )
  18. /**********************************
  19.  *                                *
  20.  * definitions for POSIX Threads  *
  21.  *                                *
  22.  **********************************/
  23.  
  24. #include <pthread.h>
  25. #ifdef HAVE_SCHED_H
  26. #include <sched.h>
  27. #endif
  28.  
  29. LDAP_BEGIN_DECL
  30.  
  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;
  34.  
  35. #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
  36.     defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
  37.     defined( _POSIX_THREADSAFE_FUNCTIONS )
  38. #define HAVE_REENTRANT_FUNCTIONS 1
  39. #endif
  40.  
  41. #if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
  42.     defined( HAVE_THR_GETCONCURRENCY )
  43. #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
  44. #endif
  45.  
  46. #if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
  47.     defined( HAVE_THR_SETCONCURRENCY )
  48. #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
  49. #endif
  50.  
  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;
  54. #endif
  55.  
  56. LDAP_END_DECL
  57.  
  58. #elif defined ( HAVE_MACH_CTHREADS )
  59. /**********************************
  60.  *                                *
  61.  * definitions for Mach CThreads  *
  62.  *                                *
  63.  **********************************/
  64.  
  65. #include <mach/cthreads.h>
  66.  
  67. LDAP_BEGIN_DECL
  68.  
  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;
  72.  
  73. LDAP_END_DECL
  74.  
  75. #elif defined( HAVE_GNU_PTH )
  76. /***********************************
  77.  *                                 *
  78.  * thread definitions for GNU Pth  *
  79.  *                                 *
  80.  ***********************************/
  81.  
  82. #define PTH_SYSCALL_SOFT 1
  83. #include <pth.h>
  84.  
  85. LDAP_BEGIN_DECL
  86.  
  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;
  90.  
  91. #if 0
  92. #define LDAP_THREAD_HAVE_RDWR 1
  93. typedef pth_rwlock_t ldap_pvt_thread_rdwr_t;
  94. #endif
  95.  
  96. LDAP_END_DECL
  97.  
  98. #elif defined( HAVE_THR )
  99. /********************************************
  100.  *                                          *
  101.  * thread definitions for Solaris LWP (THR) *
  102.  *                                          *
  103.  ********************************************/
  104.  
  105. #include <thread.h>
  106. #include <synch.h>
  107.  
  108. LDAP_BEGIN_DECL
  109.  
  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;
  113.  
  114. #define HAVE_REENTRANT_FUNCTIONS 1
  115.  
  116. #ifdef HAVE_THR_GETCONCURRENCY
  117. #define LDAP_THREAD_HAVE_GETCONCURRENCY 1
  118. #endif
  119. #ifdef HAVE_THR_SETCONCURRENCY
  120. #define LDAP_THREAD_HAVE_SETCONCURRENCY 1
  121. #endif
  122.  
  123. LDAP_END_DECL
  124.  
  125. #elif defined( HAVE_LWP )
  126. /*************************************
  127.  *                                   *
  128.  * thread definitions for SunOS LWP  *
  129.  *                                   *
  130.  *************************************/
  131.  
  132. #include <lwp/lwp.h>
  133. #include <lwp/stackdep.h>
  134. #define LDAP_THREAD_HAVE_SLEEP 1
  135.  
  136. LDAP_BEGIN_DECL
  137.  
  138. typedef thread_t        ldap_int_thread_t;
  139. typedef mon_t            ldap_int_thread_mutex_t;
  140. struct ldap_int_thread_lwp_cv {
  141.     int        lcv_created;
  142.     cv_t        lcv_cv;
  143. };
  144. typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t;
  145.  
  146. #define HAVE_REENTRANT_FUNCTIONS 1
  147.  
  148. LDAP_END_DECL
  149.  
  150. #elif defined(HAVE_NT_THREADS)
  151.  
  152. #include <process.h>
  153. #include <windows.h>
  154.  
  155. LDAP_BEGIN_DECL
  156.  
  157. typedef unsigned long    ldap_int_thread_t;
  158. typedef HANDLE    ldap_int_thread_mutex_t;
  159. typedef HANDLE    ldap_int_thread_cond_t;
  160.  
  161. LDAP_END_DECL
  162.  
  163. #else
  164.  
  165. /***********************************
  166.  *                                 *
  167.  * thread definitions for no       *
  168.  * underlying library support      *
  169.  *                                 *
  170.  ***********************************/
  171.  
  172. #ifndef NO_THREADS
  173. #define NO_THREADS 1
  174. #endif
  175.  
  176. LDAP_BEGIN_DECL
  177.  
  178. typedef int            ldap_int_thread_t;
  179. typedef int            ldap_int_thread_mutex_t;
  180. typedef int            ldap_int_thread_cond_t;
  181.  
  182. #define LDAP_THREAD_HAVE_TPOOL 1
  183. typedef int            ldap_int_thread_pool_t;
  184.  
  185. LDAP_END_DECL
  186.  
  187. #endif /* no threads support */
  188.  
  189. LDAP_BEGIN_DECL
  190.  
  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 );
  195.  
  196. #ifndef LDAP_THREAD_HAVE_TPOOL
  197. typedef struct ldap_int_thread_pool_s * ldap_int_thread_pool_t;
  198. #endif
  199.  
  200. LDAP_END_DECL
  201.  
  202. #endif /* _LDAP_INT_THREAD_H */
  203.