From cce57c018f3d2769d90f48422aac526c003440b8 Mon Sep 17 00:00:00 2001 From: muench Date: Mon, 17 Feb 2003 12:06:57 +0000 Subject: [PATCH] join with pthread-d4, branch is kept for further devel -- mm --- compat/pthread.c | 22 ++++++++++++++++------ compat/pthread.h | 31 ++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/compat/pthread.c b/compat/pthread.c index f4984eb..6ad9d84 100644 --- a/compat/pthread.c +++ b/compat/pthread.c @@ -5,22 +5,32 @@ static const char rcsId[] = "$Header$"; #include +int PTHREAD_pthread_detach(pthread_t thread) +{ + return pthread_detach(&thread); +} + int PTHREAD_pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr) { return pthread_mutex_init(mutex, mutexattr == NULL ? pthread_mutexattr_default : mutexattr); } -int PTHREAD_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) +int PTHREAD_pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *condattr) { - pthread_attr_t P_attr; + return pthread_cond_init(cond, condattr == NULL ? pthread_condattr_default : condattr); +} - P_attr = attr == NULL ? pthread_attr_default : *attr; - return pthread_create(thread, P_attr, start_routine, arg); +int PTHREAD_pthread_attr_destroy(pthread_attr_t *attr) +{ + pthread_attr_delete(attr); } -int PTHREAD_pthread_detach(pthread_t thread) +int PTHREAD_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { - return pthread_detach(&thread); + pthread_attr_t P_attr; + + P_attr = attr == NULL ? pthread_attr_default : *attr; + return pthread_create(thread, P_attr, start_routine, arg); } int PTHREAD_pthread_key_create(pthread_key_t *key, void (*destr_function) (void diff --git a/compat/pthread.h b/compat/pthread.h index 2d1a3a3..365d182 100644 --- a/compat/pthread.h +++ b/compat/pthread.h @@ -1,24 +1,43 @@ #ifndef OUR_PTHREAD_H #define OUR_PTHREAD_H +/* +Translate pthread calls conforming to the final POSIX standard (1003.1c) +to the older draft version 1003.4b. The latter one is e.g. used by +LynxOS 2.5. The translation is done according to Appendix B in +"Nichols, Buttlar, Farrell: Pthreads Programming (O'Reilly)". +*/ + #include +/* Detaching a Thread */ +#ifdef pthread_detach +#undef pthread_detach +#endif +#define pthread_detach PTHREAD_pthread_detach + /* Mutex Variables */ #ifdef pthread_mutex_init #undef pthread_mutex_init #endif #define pthread_mutex_init PTHREAD_pthread_mutex_init -/* Thread Functions */ +/* Condition Variables */ +#ifdef pthread_cond_init +#undef pthread_cond_init +#endif +#define pthread_cond_init PTHREAD_pthread_cond_init + +/* Thread Attributes */ #ifdef pthread_create #undef pthread_create #endif #define pthread_create PTHREAD_pthread_create -#ifdef pthread_detach -#undef pthread_detach +#ifdef pthread_attr_destroy +#undef pthread_attr_destroy #endif -#define pthread_detach PTHREAD_pthread_detach +#define pthread_attr_destroy PTHREAD_pthread_attr_destroy /* The pthread_once Function */ #define PTHREAD_ONCE_INIT pthread_once_init @@ -39,9 +58,11 @@ #endif #define pthread_getspecific PTHREAD_pthread_getspecific -int PTHREAD_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); int PTHREAD_pthread_detach(pthread_t thread); +int PTHREAD_pthread_attr_destroy(pthread_attr_t *attr); +int PTHREAD_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); int PTHREAD_pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); +int PTHREAD_pthread_cond_init(pthread_cond_t *mutex, const pthread_condattr_t *condattr); int PTHREAD_pthread_key_create(pthread_key_t *key, void (*destr_function) (void *)); int PTHREAD_pthread_key_delete(pthread_key_t key); void *PTHREAD_pthread_getspecific(pthread_key_t key); -- 2.43.0