openldap/include/lthread.h

233 lines
5.7 KiB
C
Raw Normal View History

1998-08-08 20:43:13 -04:00
/* lthread.h - ldap threads header file */
#ifndef _LTHREAD_H
#define _LTHREAD_H
1998-10-24 21:41:42 -04:00
#include "portable.h"
1998-08-08 23:13:49 -04:00
1998-10-24 21:41:42 -04:00
#if defined( HAVE_PTHREADS )
/**********************************
* *
* definitions for POSIX Threads *
* *
**********************************/
1998-08-08 23:13:49 -04:00
1998-10-24 21:41:42 -04:00
#include <pthread.h>
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
1998-08-08 23:13:49 -04:00
1998-10-24 21:41:42 -04:00
LDAP_BEGIN_DECL
1998-08-08 23:13:49 -04:00
#if !defined( HAVE_FUNC_PTHREAD_ATTR_INIT ) && \
defined( HAVE_FUNC_PTHREAD_ATTR_CREATE )
1998-10-24 21:41:42 -04:00
#define pthread_attr_init( a ) pthread_attr_create( a )
#endif
#if !defined( HAVE_FUNC_PTHREAD_ATTR_DESTROY ) && \
defined( HAVE_FUNC_PTHREAD_ATTR_DELETE )
1998-10-24 21:41:42 -04:00
#define pthread_attr_destroy( a ) pthread_attr_delete( a )
#endif
#if !defined( HAVE_FUNC_PTHREAD_ATTR_SETDETACHSTATE ) && \
defined( HAVE_FUNC_PTHREAD_ATTR_SETDETACHSTATE_NP )
1998-10-24 21:41:42 -04:00
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
#endif
1998-10-24 21:41:42 -04:00
#ifndef HAVE_PTHREADS_D4
1998-08-08 23:13:49 -04:00
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
1998-10-24 21:41:42 -04:00
#ifdef HAVE_SCHED_YIELD
#define pthread_yield sched_yield
#endif
#endif
1998-08-08 23:13:49 -04:00
1998-10-24 21:41:42 -04:00
LDAP_END_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#elif defined ( HAVE_MACH_CTHREADS )
/**********************************
* *
* definitions for Mach CThreads *
* *
**********************************/
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#include <mach/cthreads.h>
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
LDAP_BEGIN_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
typedef cthread_fn_t VFP;
1998-08-08 20:43:13 -04:00
typedef int pthread_attr_t;
1998-10-24 21:41:42 -04:00
typedef cthread_t pthread_t;
1998-08-08 20:43:13 -04:00
/* 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 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;
1998-10-24 21:41:42 -04:00
typedef struct mutex pthread_mutex_t;
1998-08-08 20:43:13 -04:00
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
1998-10-24 21:41:42 -04:00
typedef struct condition pthread_cond_t;
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
LDAP_END_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#elif defined( HAVE_THR )
/**************************************
* *
* thread definitions for Solaris LWP *
* *
**************************************/
1998-08-08 20:43:13 -04:00
#include <thread.h>
#include <synch.h>
1998-10-24 21:41:42 -04:00
LDAP_BEGIN_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
typedef void *(*VFP)();
1998-08-08 20:43:13 -04:00
/* 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
1998-10-24 21:41:42 -04:00
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE USYNC_THREAD
#define PTHREAD_SHARE_PROCESS USYNC_PROCESS
1998-08-08 20:43:13 -04:00
#if !defined(__SunOS_5_6)
1998-10-24 21:41:42 -04:00
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef thread_t pthread_t;
1998-08-08 20:43:13 -04:00
/* 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;
#endif /* ! sunos56 */
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
LDAP_END_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#elif defined( HAVE_LWP )
/*************************************
* *
* thread definitions for SunOS LWP *
* *
*************************************/
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#include <lwp/lwp.h>
#include <lwp/stackdep.h>
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
LDAP_BEGIN_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
typedef void *(*VFP)();
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef thread_t pthread_t;
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
1998-10-24 21:41:42 -04:00
/* 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
1998-10-24 21:41:42 -04:00
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef mon_t pthread_mutex_t;
1998-10-24 21:41:42 -04:00
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
1998-10-24 21:41:42 -04:00
/* 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;
1998-10-24 21:41:42 -04:00
LDAP_END_DECL
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#else
1998-08-08 20:43:13 -04:00
/***********************************
* *
* thread definitions for no *
* underlying library support *
* *
***********************************/
1998-10-24 21:41:42 -04:00
LDAP_BEGIN_DECL
#ifndef NO_THREADS
#define NO_THREADS 1
#endif
#ifndef PREEMPTIVE_THREADS
/* treat no threads as preemptive */
#define PREEMPTIVE_THREADS 1
#endif
1998-08-08 20:43:13 -04:00
typedef void *(*VFP)();
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef int pthread_t;
/* 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 0
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 0
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef int pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 0
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef int pthread_cond_t;
1998-10-24 21:41:42 -04:00
LDAP_END_DECL
1998-08-08 20:43:13 -04:00
#endif /* no threads support */
#endif /* _LTHREAD_H */