]> git.sur5r.net Git - openldap/blobdiff - include/lthread.h
Moved strdup/tempnam to liblutil
[openldap] / include / lthread.h
index de2dd3497fe189a976261102039155e653725641..3e611313f20ef83bff07b66b11a3b2a1891b8cff 100644 (file)
@@ -5,58 +5,53 @@
 
 #include "portable.h"
 
-LDAP_BEGIN_DECL
+#if defined( HAVE_PTHREADS )
+/**********************************
+ *                                *
+ * definitions for POSIX Threads  *
+ *                                *
+ **********************************/
 
-#if defined ( THREAD_NEXT_CTHREADS )
+#include <pthread.h>
+#ifdef HAVE_SCHED_H
+#include <sched.h>
+#endif
 
-#define _THREAD
+LDAP_BEGIN_DECL
 
-#include <mach/cthreads.h>
+#if defined( HAVE_DCE )
+/* dce threads are preemptive */
 
-typedef cthread_fn_t   VFP;
-typedef int            pthread_attr_t;
-typedef cthread_t      pthread_t;
+#define pthread_attr_init( a )         pthread_attr_create( a )
+#define pthread_attr_destroy( a )      pthread_attr_delete( a )
+#define pthread_attr_setdetachstate( a, b ) \
+                                       pthread_attr_setdetach_np( a, b )
 
-/* default attr states */
+#elif !defined(HAVE_PTHREADS_D4)
 #define pthread_mutexattr_default      NULL
 #define pthread_condattr_default       NULL
 
-/* thread state - joinable or not */
-#define PTHREAD_CREATE_JOINABLE        0
-#define PTHREAD_CREATE_DETACHED        1
-/* thread scope - who is in scheduling pool */
-#define PTHREAD_SCOPE_PROCESS  0
-#define PTHREAD_SCOPE_SYSTEM   1
-
-/* mutex attributes and mutex type */
-typedef int    pthread_mutexattr_t;
-typedef struct mutex pthread_mutex_t;
-
-/* mutex and condition variable scope - process or system */
-#define PTHREAD_SHARE_PRIVATE  0
-#define PTHREAD_SHARE_PROCESS  1
+#ifdef HAVE_SCHED_YIELD
+#define pthread_yield sched_yield
+#endif
+#endif
 
-/* condition variable attributes and condition variable type */
-typedef int    pthread_condattr_t;
-typedef struct condition pthread_cond_t;
-
-#elif defined( THREAD_SUNOS4_LWP )
-/***********************************
- *                                 *
- * thread definitions for sunos4   *
- *                                 *
- ***********************************/
+LDAP_END_DECL
 
-#define _THREAD
+#elif defined ( HAVE_MACH_CTHREADS )
+/**********************************
+ *                                *
+ * definitions for Mach CThreads  *
+ *                                *
+ **********************************/
 
-#include <lwp/lwp.h>
-#include <lwp/stackdep.h>
+#include <mach/cthreads.h>
 
-typedef void   *(*VFP)();
+LDAP_BEGIN_DECL
 
-/* thread attributes and thread type */
+typedef cthread_fn_t   VFP;
 typedef int            pthread_attr_t;
-typedef thread_t       pthread_t;
+typedef cthread_t      pthread_t;
 
 /* default attr states */
 #define pthread_mutexattr_default      NULL
@@ -71,7 +66,7 @@ typedef thread_t      pthread_t;
 
 /* mutex attributes and mutex type */
 typedef int    pthread_mutexattr_t;
-typedef mon_t  pthread_mutex_t;
+typedef struct mutex pthread_mutex_t;
 
 /* mutex and condition variable scope - process or system */
 #define PTHREAD_SHARE_PRIVATE  0
@@ -79,35 +74,23 @@ typedef mon_t       pthread_mutex_t;
 
 /* condition variable attributes and condition variable type */
 typedef int    pthread_condattr_t;
-typedef struct lwpcv {
-       int             lcv_created;
-       cv_t            lcv_cv;
-} pthread_cond_t;
-
-#else /* end sunos4 */
+typedef struct condition pthread_cond_t;
 
-#if defined( THREAD_SUNOS5_LWP )
-/***********************************
- *                                 *
- * thread definitions for sunos5   *
- *                                 *
- ***********************************/
+LDAP_END_DECL
 
-#define _THREAD
+#elif defined( HAVE_LWP_THR )
+/**************************************
+ *                                    *
+ * thread definitions for Solaris LWP *
+ *                                    *
+ **************************************/
 
 #include <thread.h>
 #include <synch.h>
 
-typedef void   *(*VFP)();
-
-/* sunos5 threads are preemptive */
-#define PTHREAD_PREEMPTIVE     1
+LDAP_BEGIN_DECL
 
-#if !defined(__SunOS_5_6)
-/* thread attributes and thread type */
-typedef int            pthread_attr_t;
-typedef thread_t       pthread_t;
-#endif /* ! sunos56 */
+typedef void   *(*VFP)();
 
 /* default attr states */
 #define pthread_mutexattr_default      NULL
@@ -119,75 +102,74 @@ typedef thread_t  pthread_t;
 /* thread scope - who is in scheduling pool */
 #define PTHREAD_SCOPE_PROCESS   0
 #define PTHREAD_SCOPE_SYSTEM    THR_BOUND
+/* mutex and condition variable scope - process or system */
+#define PTHREAD_SHARE_PRIVATE   USYNC_THREAD
+#define PTHREAD_SHARE_PROCESS   USYNC_PROCESS
+
 
 #if !defined(__SunOS_5_6)
+/* thread attributes and thread type */
+typedef int            pthread_attr_t;
+typedef thread_t       pthread_t;
+
 /* mutex attributes and mutex type */
 typedef int    pthread_mutexattr_t;
 typedef mutex_t        pthread_mutex_t;
-#endif /* ! sunos56 */
-
-/* mutex and condition variable scope - process or system */
-#define PTHREAD_SHARE_PRIVATE   USYNC_THREAD
-#define PTHREAD_SHARE_PROCESS   USYNC_PROCESS
 
-#if !defined(__SunOS_5_6)
 /* condition variable attributes and condition variable type */
 typedef int     pthread_condattr_t;
 typedef cond_t pthread_cond_t;
 #endif /* ! sunos56 */
 
-#else /* end sunos5 */
-
-#if defined( THREAD_MIT_PTHREADS )
-/***********************************
- *                                 *
- * definitions for mit pthreads    *
- *                                 *
- ***********************************/
-
-#define _THREAD
-
-#include <pthread.h>
+LDAP_END_DECL
 
-#else /* end mit pthreads */
+#elif defined( HAVE_LWP )
+/*************************************
+ *                                   *
+ * thread definitions for SunOS LWP  *
+ *                                   *
+ *************************************/
 
-#if defined( THREAD_DCE_PTHREADS )
-/***********************************
- *                                 *
- * definitions for mit pthreads    *
- *                                 *
- ***********************************/
-
-#define _THREAD
+#include <lwp/lwp.h>
+#include <lwp/stackdep.h>
 
-#include <pthread.h>
+LDAP_BEGIN_DECL
 
-/* dce threads are preemptive */
-#define PTHREAD_PREEMPTIVE     1
+typedef void   *(*VFP)();
 
-#define pthread_attr_init( a )         pthread_attr_create( a )
-#define pthread_attr_destroy( a )      pthread_attr_delete( a )
-#define pthread_attr_setdetachstate( a, b ) \
-                                       pthread_attr_setdetach_np( a, b )
+/* thread attributes and thread type */
+typedef int            pthread_attr_t;
+typedef thread_t       pthread_t;
 
-#else /* end dce pthreads */
+/* default attr states */
+#define pthread_mutexattr_default      NULL
+#define pthread_condattr_default       NULL
 
-#if defined( POSIX_THREADS )
+/* thread state - joinable or not */
+#define PTHREAD_CREATE_JOINABLE        0
+#define PTHREAD_CREATE_DETACHED        1
+/* thread scope - who is in scheduling pool */
+#define PTHREAD_SCOPE_PROCESS  0
+#define PTHREAD_SCOPE_SYSTEM   1
 
-#define _THREAD
+/* mutex attributes and mutex type */
+typedef int    pthread_mutexattr_t;
+typedef mon_t  pthread_mutex_t;
 
-#include <pthread.h>
+/* mutex and condition variable scope - process or system */
+#define PTHREAD_SHARE_PRIVATE  0
+#define PTHREAD_SHARE_PROCESS  1
 
-#define pthread_mutexattr_default      NULL
-#define pthread_condattr_default       NULL
+/* condition variable attributes and condition variable type */
+typedef int    pthread_condattr_t;
+typedef struct lwpcv {
+       int             lcv_created;
+       cv_t            lcv_cv;
+} pthread_cond_t;
 
-#endif /* posix threads */
-#endif /* dce pthreads */
-#endif /* mit pthreads */
-#endif /* sunos5 */
-#endif /* sunos4 */
+LDAP_END_DECL
 
-#ifndef _THREAD
+#else
 
 /***********************************
  *                                 *
@@ -196,6 +178,8 @@ typedef cond_t      pthread_cond_t;
  *                                 *
  ***********************************/
 
+LDAP_BEGIN_DECL
+
 typedef void   *(*VFP)();
 
 /* thread attributes and thread type */
@@ -225,8 +209,7 @@ typedef int pthread_mutex_t;
 typedef int     pthread_condattr_t;
 typedef int    pthread_cond_t;
 
-#endif /* no threads support */
-
 LDAP_END_DECL
 
+#endif /* no threads support */
 #endif /* _LTHREAD_H */