X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Flthread.h;h=3485406d93652ba0626294d9a6ee8211eef6200f;hb=9697ad210a9e288c26dc3a62df87128ecc3a9f20;hp=8cee54cb12904fc63673658d29384802ec672a33;hpb=adc2134f03a0d3b30e3e93e54d8c9117bd0d2534;p=openldap diff --git a/include/lthread.h b/include/lthread.h index 8cee54cb12..3485406d93 100644 --- a/include/lthread.h +++ b/include/lthread.h @@ -3,12 +3,65 @@ #ifndef _LTHREAD_H #define _LTHREAD_H -#if defined ( THREAD_NEXT_CTHREADS ) +#include "portable.h" -#define _THREAD +#if defined( HAVE_PTHREADS ) +/********************************** + * * + * definitions for POSIX Threads * + * * + **********************************/ + +#include +#ifdef HAVE_SCHED_H +#include +#endif + +LDAP_BEGIN_DECL + +#if !defined( HAVE_PTHREAD_ATTR_INIT ) && \ + defined( HAVE_PTHREAD_ATTR_CREATE ) +#define pthread_attr_init( a ) pthread_attr_create( a ) +#endif + +#if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \ + defined( HAVE_PTHREAD_ATTR_DELETE ) +#define pthread_attr_destroy( a ) pthread_attr_delete( a ) +#endif + +#if !defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) && \ + defined( HAVE_PTHREAD_ATTR_SETDETACH_NP ) +#define pthread_attr_setdetachstate( a, b ) \ + pthread_attr_setdetach_np( a, b ) +#endif + +#ifndef HAVE_PTHREAD_KILL +/* missing pthread_kill(), define prototype */ +LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig )); +#endif + +#ifndef HAVE_PTHREADS_D4 +#define pthread_mutexattr_default NULL +#define pthread_condattr_default NULL + +#ifdef HAVE_SCHED_YIELD +#define pthread_yield sched_yield +#endif +#endif + +LDAP_END_DECL + +#elif defined ( HAVE_MACH_CTHREADS ) +/********************************** + * * + * definitions for Mach CThreads * + * * + **********************************/ #include +LDAP_BEGIN_DECL + typedef cthread_fn_t VFP; typedef int pthread_attr_t; typedef cthread_t pthread_t; @@ -36,18 +89,65 @@ typedef struct mutex pthread_mutex_t; typedef int pthread_condattr_t; typedef struct condition pthread_cond_t; -#elif defined( THREAD_SUNOS4_LWP ) -/*********************************** - * * - * thread definitions for sunos4 * - * * - ***********************************/ +LDAP_END_DECL + +#elif defined( HAVE_THR ) +/************************************** + * * + * thread definitions for Solaris LWP * + * * + **************************************/ + +#include +#include + +LDAP_BEGIN_DECL + +typedef void *(*VFP)(); + +/* default attr states */ +#define pthread_mutexattr_default NULL +#define pthread_condattr_default NULL + +/* thread state - joinable or not */ +#define PTHREAD_CREATE_JOINABLE 0 +#define PTHREAD_CREATE_DETACHED THR_DETACHED +/* 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 + +/* 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; + +/* condition variable attributes and condition variable type */ +typedef int pthread_condattr_t; +typedef cond_t pthread_cond_t; -#define _THREAD +LDAP_END_DECL + +#elif defined( HAVE_LWP ) +/************************************* + * * + * thread definitions for SunOS LWP * + * * + *************************************/ #include #include +LDAP_BEGIN_DECL + +stkalign_t *get_stack( int *stacknop ); +void free_stack( int *stackno ); + typedef void *(*VFP)(); /* thread attributes and thread type */ @@ -80,30 +180,18 @@ typedef struct lwpcv { cv_t lcv_cv; } pthread_cond_t; -#else /* end sunos4 */ - -#if defined( THREAD_SUNOS5_LWP ) -/*********************************** - * * - * thread definitions for sunos5 * - * * - ***********************************/ - -#define _THREAD +LDAP_END_DECL -#include -#include +#elif HAVE_NT_THREADS -typedef void *(*VFP)(); +#include +#include -/* sunos5 threads are preemptive */ -#define PTHREAD_PREEMPTIVE 1 +typedef void (*VFP)(void*); -#if !defined(__SunOS_5_6) /* thread attributes and thread type */ typedef int pthread_attr_t; -typedef thread_t pthread_t; -#endif /* ! sunos56 */ +typedef HANDLE pthread_t; /* default attr states */ #define pthread_mutexattr_default NULL @@ -111,80 +199,26 @@ typedef thread_t pthread_t; /* thread state - joinable or not */ #define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED THR_DETACHED +#define PTHREAD_CREATE_DETACHED 0 /* thread scope - who is in scheduling pool */ #define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM THR_BOUND +#define PTHREAD_SCOPE_SYSTEM 0 -#if !defined(__SunOS_5_6) /* mutex attributes and mutex type */ -typedef int pthread_mutexattr_t; -typedef mutex_t pthread_mutex_t; -#endif /* ! sunos56 */ +typedef int pthread_mutexattr_t; +typedef HANDLE pthread_mutex_t; /* 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 - -#else /* end mit pthreads */ - -#if defined( THREAD_DCE_PTHREADS ) -/*********************************** - * * - * definitions for mit pthreads * - * * - ***********************************/ - -#define _THREAD - -#include - -/* dce threads are preemptive */ -#define PTHREAD_PREEMPTIVE 1 - -#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 ) - -#else /* end dce pthreads */ - -#if defined( POSIX_THREADS ) - -#define _THREAD - -#include -#include - -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL +typedef HANDLE pthread_cond_t; +typedef int any_t; -#endif /* posix threads */ -#endif /* dce pthreads */ -#endif /* mit pthreads */ -#endif /* sunos5 */ -#endif /* sunos4 */ -#ifndef _THREAD +#else /*********************************** * * @@ -193,6 +227,12 @@ typedef cond_t pthread_cond_t; * * ***********************************/ +LDAP_BEGIN_DECL + +#ifndef NO_THREADS +#define NO_THREADS 1 +#endif + typedef void *(*VFP)(); /* thread attributes and thread type */ @@ -222,5 +262,7 @@ typedef int pthread_mutex_t; typedef int pthread_condattr_t; typedef int pthread_cond_t; +LDAP_END_DECL + #endif /* no threads support */ #endif /* _LTHREAD_H */