From 46c3cddad45949774bfeda3461d522c0cb26b93f Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 23 Sep 1998 08:56:54 +0000 Subject: [PATCH] more ldap_cdefs.h, less bridge.h --- include/ldif.h | 33 +++++++++---------------- include/lthread.h | 7 ++++++ include/lthread_rdwr.h | 46 +++++++++++++++++++++++++++++++++++ libraries/liblthread/thread.c | 7 ++++-- 4 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 include/lthread_rdwr.h diff --git a/include/ldif.h b/include/ldif.h index dd2b339193..c24bb0a152 100644 --- a/include/ldif.h +++ b/include/ldif.h @@ -13,9 +13,9 @@ #ifndef _LDIF_H #define _LDIF_H -#ifdef __cplusplus -extern "C" { -#endif +#include + +LDAP_BEGIN_DECL #define LINE_WIDTH 76 /* maximum length of LDIF lines */ @@ -34,23 +34,14 @@ extern "C" { */ #define LDIF_SIZE_NEEDED(tlen,vlen) \ ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ - + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LINE_WIDTH * 2 )) - - -#ifdef NEEDPROTOS -int str_parse_line( char *line, char **type, char **value, int *vlen); -char * str_getline( char **next ); -void put_type_and_value( char **out, char *t, char *val, int vlen ); -char *ldif_type_and_value( char *type, char *val, int vlen ); -#else /* NEEDPROTOS */ -int str_parse_line(); -char * str_getline(); -void put_type_and_value(); -char *ldif_type_and_value(); -#endif /* NEEDPROTOS */ - -#ifdef __cplusplus -} -#endif + + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 )) + + +int str_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen)); +char * str_getline LDAP_P(( char **next )); +void put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen )); +char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen )); + +LDAP_END_DECL #endif /* _LDIF_H */ diff --git a/include/lthread.h b/include/lthread.h index d3fd3d0ec6..e9a4ee4f46 100644 --- a/include/lthread.h +++ b/include/lthread.h @@ -3,6 +3,10 @@ #ifndef _LTHREAD_H #define _LTHREAD_H +#include + +LDAP_BEGIN_DECL + #if defined ( THREAD_NEXT_CTHREADS ) #define _THREAD @@ -222,4 +226,7 @@ typedef int pthread_condattr_t; typedef int pthread_cond_t; #endif /* no threads support */ + +LDAP_END_DECL + #endif /* _LTHREAD_H */ diff --git a/include/lthread_rdwr.h b/include/lthread_rdwr.h new file mode 100644 index 0000000000..1c751f39a6 --- /dev/null +++ b/include/lthread_rdwr.h @@ -0,0 +1,46 @@ +#ifndef _LTHREAD_RDWR_H +#define _LTHREAD_RDWR_H 1 + +/******************************************************** + * An example source module to accompany... + * + * "Using POSIX Threads: Programming with Pthreads" + * by Brad nichols, Dick Buttlar, Jackie Farrell + * O'Reilly & Associates, Inc. + * + ******************************************************** + * + * Include file for reader/writer locks + * + */ + +#include + +LDAP_BEGIN_DECL + +typedef struct rdwr_var { + int readers_reading; + int writer_writing; + pthread_mutex_t mutex; + pthread_cond_t lock_free; +} pthread_rdwr_t; + +typedef void * pthread_rdwrattr_t; + +#define pthread_rdwrattr_default NULL; + +int pthread_rdwr_init_np LDAP_P((pthread_rdwr_t *rdwrp, pthread_rdwrattr_t *attrp)); +int pthread_rdwr_rlock_np LDAP_P((pthread_rdwr_t *rdwrp)); +int pthread_rdwr_runlock_np LDAP_P((pthread_rdwr_t *rdwrp)); +int pthread_rdwr_wlock_np LDAP_P((pthread_rdwr_t *rdwrp)); +int pthread_rdwr_wunlock_np LDAP_P((pthread_rdwr_t *rdwrp)); + +#ifdef LDAP_DEBUG +int pthread_rdwr_rchk_np LDAP_P((pthread_rdwr_t *rdwrp)); +int pthread_rdwr_wchk_np LDAP_P((pthread_rdwr_t *rdwrp)); +int pthread_rdwr_rwchk_np LDAP_P((pthread_rdwr_t *rdwrp)); +#endif /* LDAP_DEBUG */ + +LDAP_END_DECL + +#endif /* _LTHREAD_RDWR_H */ diff --git a/libraries/liblthread/thread.c b/libraries/liblthread/thread.c index d0a62d5a81..d4fea7e477 100644 --- a/libraries/liblthread/thread.c +++ b/libraries/liblthread/thread.c @@ -1,6 +1,9 @@ /* thread.c - glue routines to provide a consistent thread interface */ -#include -#include "lthread.h" + +#define DISABLE_BRIDGE +#include "portable.h" + +#include #if defined( THREAD_NEXT_CTHREADS ) -- 2.39.5