From: Mark Valence Date: Tue, 6 Jun 2000 19:59:34 +0000 (+0000) Subject: In preparation for thread pools X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2731 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=72bf2552ebbcc15db956d0407d00c4a8ad863abb;p=openldap In preparation for thread pools --- diff --git a/include/ldap_int_thread.h b/include/ldap_int_thread.h new file mode 100644 index 0000000000..7f0257cdfa --- /dev/null +++ b/include/ldap_int_thread.h @@ -0,0 +1,255 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* ldap_int_thread.h - ldap internal thread wrappers header file */ + +#ifndef _LDAP_INT_THREAD_H +#define _LDAP_INT_THREAD_H + +#include "ldap_cdefs.h" + +#if defined( HAVE_PTHREADS ) +/********************************** + * * + * definitions for POSIX Threads * + * * + **********************************/ + +#include +#ifdef HAVE_SCHED_H +#include +#endif + +LDAP_BEGIN_DECL + +typedef pthread_t ldap_int_thread_t; +typedef pthread_mutex_t ldap_int_thread_mutex_t; +typedef pthread_cond_t ldap_int_thread_cond_t; + +#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \ + defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \ + defined( _POSIX_THREADSAFE_FUNCTIONS ) +#define HAVE_REENTRANT_FUNCTIONS 1 +#endif + +#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \ + defined( HAVE_THR_GETCONCURRENCY ) +#define HAVE_GETCONCURRENCY 1 +#endif + +#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \ + defined( HAVE_THR_SETCONCURRENCY ) +#define HAVE_SETCONCURRENCY 1 +#endif + +LDAP_END_DECL + +#elif defined ( HAVE_MACH_CTHREADS ) +/********************************** + * * + * definitions for Mach CThreads * + * * + **********************************/ + +#include + +LDAP_BEGIN_DECL + +typedef cthread_t ldap_int_thread_t; +typedef struct mutex ldap_int_thread_mutex_t; +typedef struct condition ldap_int_thread_cond_t; + +LDAP_END_DECL + +#elif defined( HAVE_GNU_PTH ) +/*********************************** + * * + * thread definitions for GNU Pth * + * * + ***********************************/ + +#define PTH_SYSCALL_SOFT 1 +#include + +LDAP_BEGIN_DECL + +typedef pth_t ldap_int_thread_t; +typedef pth_mutex_t ldap_int_thread_mutex_t; +typedef pth_cond_t ldap_int_thread_cond_t; + +LDAP_END_DECL + + +#elif defined( HAVE_THR ) +/******************************************** + * * + * thread definitions for Solaris LWP (THR) * + * * + ********************************************/ + +#include +#include + +LDAP_BEGIN_DECL + +typedef thread_t ldap_int_thread_t; +typedef mutex_t ldap_int_thread_mutex_t; +typedef cond_t ldap_int_thread_cond_t; + +#define HAVE_REENTRANT_FUNCTIONS 1 + +#ifdef HAVE_THR_GETCONCURRENCY +#define HAVE_GETCONCURRENCY 1 +#endif +#ifdef HAVE_THR_SETCONCURRENCY +#define HAVE_SETCONCURRENCY 1 +#endif + +LDAP_END_DECL + +#elif defined( HAVE_LWP ) +/************************************* + * * + * thread definitions for SunOS LWP * + * * + *************************************/ + +#include +#include + +LDAP_BEGIN_DECL + +typedef thread_t ldap_int_thread_t; +typedef mon_t ldap_int_thread_mutex_t; +struct ldap_int_thread_lwp_cv { + int lcv_created; + cv_t lcv_cv; +}; +typedef struct ldap_int_thread_lwp_cv ldap_int_thread_cond_t; + +#define HAVE_REENTRANT_FUNCTIONS 1 + +LDAP_END_DECL + +#elif defined(HAVE_NT_THREADS) + +LDAP_BEGIN_DECL + +#include +#include + +typedef unsigned long ldap_int_thread_t; +typedef HANDLE ldap_int_thread_mutex_t; +typedef HANDLE ldap_int_thread_cond_t; + +LDAP_END_DECL + +#else + +/*********************************** + * * + * thread definitions for no * + * underlying library support * + * * + ***********************************/ + +LDAP_BEGIN_DECL + +#ifndef NO_THREADS +#define NO_THREADS 1 +#endif + +typedef int ldap_int_thread_t; +typedef int ldap_int_thread_mutex_t; +typedef int ldap_int_thread_cond_t; + +LDAP_END_DECL + +#endif /* no threads support */ + +LDAP_BEGIN_DECL + +LIBLDAP_F( int ) +ldap_int_thread_initialize LDAP_P(( void )); + +LIBLDAP_F( int ) +ldap_int_thread_destroy LDAP_P(( void )); + +LIBLDAP_F( unsigned int ) +ldap_int_thread_sleep LDAP_P(( unsigned int s )); + +#ifdef HAVE_GETCONCURRENCY +LIBLDAP_F( int ) +ldap_int_thread_get_concurrency LDAP_P(( void )); +#endif + +#ifdef HAVE_SETCONCURRENCY +# ifndef LDAP_THREAD_CONCURRENCY + /* three concurrent threads should be enough */ +# define LDAP_THREAD_CONCURRENCY 3 +# endif +LIBLDAP_F( int ) +ldap_int_thread_set_concurrency LDAP_P(( int )); +#endif + +LIBLDAP_F( int ) +ldap_int_thread_create LDAP_P(( + ldap_int_thread_t * thread, + int detach, + void *(*start_routine)( void * ), + void *arg)); + +LIBLDAP_F( void ) +ldap_int_thread_exit LDAP_P(( void *retval )); + +LIBLDAP_F( int ) +ldap_int_thread_join LDAP_P(( ldap_int_thread_t thread, void **status )); + +LIBLDAP_F( int ) +ldap_int_thread_kill LDAP_P(( ldap_int_thread_t thread, int signo )); + +LIBLDAP_F( int ) +ldap_int_thread_yield LDAP_P(( void )); + +LIBLDAP_F( int ) +ldap_int_thread_cond_init LDAP_P(( ldap_int_thread_cond_t *cond )); + +LIBLDAP_F( int ) +ldap_int_thread_cond_destroy LDAP_P(( ldap_int_thread_cond_t *cond )); + +LIBLDAP_F( int ) +ldap_int_thread_cond_signal LDAP_P(( ldap_int_thread_cond_t *cond )); + +LIBLDAP_F( int ) +ldap_int_thread_cond_broadcast LDAP_P(( ldap_int_thread_cond_t *cond )); + +LIBLDAP_F( int ) +ldap_int_thread_cond_wait LDAP_P(( + ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex )); + +LIBLDAP_F( int ) +ldap_int_thread_mutex_init LDAP_P(( ldap_int_thread_mutex_t *mutex )); + +LIBLDAP_F( int ) +ldap_int_thread_mutex_destroy LDAP_P(( ldap_int_thread_mutex_t *mutex )); + +LIBLDAP_F( int ) +ldap_int_thread_mutex_lock LDAP_P(( ldap_int_thread_mutex_t *mutex )); + +LIBLDAP_F( int ) +ldap_int_thread_mutex_trylock LDAP_P(( ldap_int_thread_mutex_t *mutex )); + +LIBLDAP_F( int ) +ldap_int_thread_mutex_unlock LDAP_P(( ldap_int_thread_mutex_t *mutex )); + +LDAP_END_DECL + +#endif /* _LDAP_INT_THREAD_H */ diff --git a/include/ldap_pvt_thread.h b/include/ldap_pvt_thread.h index cbfab8597a..f336feafa9 100644 --- a/include/ldap_pvt_thread.h +++ b/include/ldap_pvt_thread.h @@ -14,167 +14,14 @@ #define _LDAP_PVT_THREAD_H #include "ldap_cdefs.h" - -#if defined( HAVE_PTHREADS ) -/********************************** - * * - * definitions for POSIX Threads * - * * - **********************************/ - -#include -#ifdef HAVE_SCHED_H -#include -#endif - -LDAP_BEGIN_DECL - -typedef pthread_t ldap_pvt_thread_t; -typedef pthread_mutex_t ldap_pvt_thread_mutex_t; -typedef pthread_cond_t ldap_pvt_thread_cond_t; - -#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \ - defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \ - defined( _POSIX_THREADSAFE_FUNCTIONS ) -#define HAVE_REENTRANT_FUNCTIONS 1 -#endif - -#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \ - defined( HAVE_THR_GETCONCURRENCY ) -#define HAVE_GETCONCURRENCY 1 -#endif - -#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \ - defined( HAVE_THR_SETCONCURRENCY ) -#define HAVE_SETCONCURRENCY 1 -#endif - -LDAP_END_DECL - -#elif defined ( HAVE_MACH_CTHREADS ) -/********************************** - * * - * definitions for Mach CThreads * - * * - **********************************/ - -#include - -LDAP_BEGIN_DECL - -typedef cthread_t ldap_pvt_thread_t; -typedef struct mutex ldap_pvt_thread_mutex_t; -typedef struct condition ldap_pvt_thread_cond_t; - -LDAP_END_DECL - -#elif defined( HAVE_GNU_PTH ) -/*********************************** - * * - * thread definitions for GNU Pth * - * * - ***********************************/ - -#define PTH_SYSCALL_SOFT 1 -#include - -LDAP_BEGIN_DECL - -typedef pth_t ldap_pvt_thread_t; -typedef pth_mutex_t ldap_pvt_thread_mutex_t; -typedef pth_cond_t ldap_pvt_thread_cond_t; - -LDAP_END_DECL - - -#elif defined( HAVE_THR ) -/******************************************** - * * - * thread definitions for Solaris LWP (THR) * - * * - ********************************************/ - -#include -#include - -LDAP_BEGIN_DECL - -typedef thread_t ldap_pvt_thread_t; -typedef mutex_t ldap_pvt_thread_mutex_t; -typedef cond_t ldap_pvt_thread_cond_t; - -#define HAVE_REENTRANT_FUNCTIONS 1 - -#ifdef HAVE_THR_GETCONCURRENCY -#define HAVE_GETCONCURRENCY 1 -#endif -#ifdef HAVE_THR_SETCONCURRENCY -#define HAVE_SETCONCURRENCY 1 -#endif - -LDAP_END_DECL - -#elif defined( HAVE_LWP ) -/************************************* - * * - * thread definitions for SunOS LWP * - * * - *************************************/ - -#include -#include +#include "ldap_int_thread.h" LDAP_BEGIN_DECL -typedef thread_t ldap_pvt_thread_t; -typedef mon_t ldap_pvt_thread_mutex_t; -struct ldap_pvt_thread_lwp_cv { - int lcv_created; - cv_t lcv_cv; -}; -typedef struct ldap_pvt_thread_lwp_cv ldap_pvt_thread_cond_t; +typedef ldap_int_thread_t ldap_pvt_thread_t; +typedef ldap_int_thread_mutex_t ldap_pvt_thread_mutex_t; +typedef ldap_int_thread_cond_t ldap_pvt_thread_cond_t; -#define HAVE_REENTRANT_FUNCTIONS 1 - -LDAP_END_DECL - -#elif defined(HAVE_NT_THREADS) - -LDAP_BEGIN_DECL - -#include -#include - -typedef unsigned long ldap_pvt_thread_t; -typedef HANDLE ldap_pvt_thread_mutex_t; -typedef HANDLE ldap_pvt_thread_cond_t; - -LDAP_END_DECL - -#else - -/*********************************** - * * - * thread definitions for no * - * underlying library support * - * * - ***********************************/ - -LDAP_BEGIN_DECL - -#ifndef NO_THREADS -#define NO_THREADS 1 -#endif - -typedef int ldap_pvt_thread_t; -typedef int ldap_pvt_thread_mutex_t; -typedef int ldap_pvt_thread_cond_t; - -LDAP_END_DECL - -#endif /* no threads support */ - -LDAP_BEGIN_DECL LIBLDAP_F( int ) ldap_pvt_thread_initialize LDAP_P(( void )); @@ -185,19 +32,15 @@ ldap_pvt_thread_destroy LDAP_P(( void )); LIBLDAP_F( unsigned int ) ldap_pvt_thread_sleep LDAP_P(( unsigned int s )); -#ifdef HAVE_GETCONCURRENCY LIBLDAP_F( int ) ldap_pvt_thread_get_concurrency LDAP_P(( void )); -#endif -#ifdef HAVE_SETCONCURRENCY -# ifndef LDAP_THREAD_CONCURRENCY +#ifndef LDAP_THREAD_CONCURRENCY /* three concurrent threads should be enough */ -# define LDAP_THREAD_CONCURRENCY 3 -# endif +#define LDAP_THREAD_CONCURRENCY 3 +#endif LIBLDAP_F( int ) ldap_pvt_thread_set_concurrency LDAP_P(( int )); -#endif #define LDAP_PVT_THREAD_CREATE_JOINABLE 0 #define LDAP_PVT_THREAD_CREATE_DETACHED 1 diff --git a/libraries/libldap_r/Makefile.in b/libraries/libldap_r/Makefile.in index 3455e8a2c8..d5afab47cf 100644 --- a/libraries/libldap_r/Makefile.in +++ b/libraries/libldap_r/Makefile.in @@ -21,7 +21,7 @@ XXSRCS = apitest.c test.c tmpltest.c extended.c \ charray.c tls.c dn.c os-local.c dnssrv.c \ utf-8.c SRCS = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \ - thr_pth.c thr_sleep.c thr_stub.c rdwr.c + thr_pth.c thr_sleep.c thr_stub.c rdwr.c threads.c OBJS = extended.lo \ bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \ modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \ @@ -31,7 +31,7 @@ OBJS = extended.lo \ request.lo os-ip.lo url.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \ - thr_pth.lo thr_sleep.lo thr_stub.lo rdwr.lo \ + thr_pth.lo thr_sleep.lo thr_stub.lo rdwr.lo threads.lo \ charray.lo tls.lo dn.lo os-local.lo dnssrv.lo \ utf-8.lo diff --git a/libraries/libldap_r/thr_cthreads.c b/libraries/libldap_r/thr_cthreads.c index d9604f81b9..807ecde35e 100644 --- a/libraries/libldap_r/thr_cthreads.c +++ b/libraries/libldap_r/thr_cthreads.c @@ -14,7 +14,7 @@ #include "portable.h" #if defined( HAVE_MACH_CTHREADS ) -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" /*********************************************************************** * * @@ -24,19 +24,19 @@ ***********************************************************************/ int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { return 0; } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { return 0; } int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)( void *), void *arg) { @@ -45,13 +45,13 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { cthread_exit( (any_t) retval ); } int -ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +ldap_int_thread_join( ldap_int_thread_t thread, void **thread_return ) { void *status; status = (void *) cthread_join ( thread ); @@ -63,56 +63,56 @@ ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { return 0; } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { cthread_yield(); return 0; } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { condition_init( cond ); return( 0 ); } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_destroy( ldap_int_thread_cond_t *cond ) { condition_clear( cond ); return( 0 ); } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { condition_signal( cond ); return( 0 ); } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cond ) { condition_broadcast( cond ); return( 0 ); } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { condition_wait( cond, mutex ); return( 0 ); } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { mutex_init( mutex ); mutex->name = NULL; @@ -120,28 +120,28 @@ ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { mutex_clear( mutex ); return ( 0 ); } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { mutex_lock( mutex ); return ( 0 ); } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { mutex_unlock( mutex ); return ( 0 ); } int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mutex ) { return mutex_try_lock( mutex ); } diff --git a/libraries/libldap_r/thr_lwp.c b/libraries/libldap_r/thr_lwp.c index e13efd5b10..bdb00e3326 100644 --- a/libraries/libldap_r/thr_lwp.c +++ b/libraries/libldap_r/thr_lwp.c @@ -35,7 +35,7 @@ #include "ldap-int.h" -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" #include #include @@ -47,7 +47,7 @@ * Initialize LWP by spinning of a schedular */ int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { thread_t tid; stkalign_t *stack; @@ -62,7 +62,7 @@ ldap_pvt_thread_initialize( void ) } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { /* need to destory lwp_scheduler thread and clean up private variables */ @@ -76,7 +76,7 @@ struct stackinfo { static struct stackinfo *stacks; -static stkalign_t * ldap_pvt_thread_get_stack( int *stacknop ) +static stkalign_t * ldap_int_thread_get_stack( int *stacknop ) { int i; @@ -122,7 +122,7 @@ static stkalign_t * ldap_pvt_thread_get_stack( int *stacknop ) } static void -ldap_pvt_thread_free_stack( int stackno ) +ldap_int_thread_free_stack( int stackno ) { if ( stackno < 0 || stackno > MAX_THREADS ) { Debug( LDAP_DEBUG_ANY, "free_stack of bogus stack %d\n", @@ -137,11 +137,11 @@ lwp_create_stack( void *(*func)(), void *arg, int stackno ) { (*func)( arg ); - ldap_pvt_thread_free_stack( stackno ); + ldap_int_thread_free_stack( stackno ); } int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)( void *), void *arg) @@ -149,7 +149,7 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, stkalign_t *stack; int stackno; - if ( (stack = ldap_pvt_thread_get_stack( &stackno )) == NULL ) { + if ( (stack = ldap_int_thread_get_stack( &stackno )) == NULL ) { return( -1 ); } return( lwp_create( thread, lwp_create_stack, MINPRIO, 0, @@ -157,13 +157,13 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { lwp_destroy( SELF ); } unsigned int -ldap_pvt_thread_sleep( +ldap_int_thread_sleep( unsigned int interval ) { @@ -265,27 +265,27 @@ lwp_scheduler( } int -ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +ldap_int_thread_join( ldap_int_thread_t thread, void **thread_return ) { lwp_join( thread ); return 0; } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { return 0; } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { lwp_yield( SELF ); return 0; } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { /* * lwp cv_create requires the monitor id be passed in @@ -301,14 +301,14 @@ ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { return( cond->lcv_created ? cv_notify( cv->lcv_cv ) : 0 ); } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { if ( ! cond->lcv_created ) { cv_create( &cond->lcv_cv, *mutex ); @@ -319,43 +319,43 @@ ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { return( mon_create( mutex ) ); } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { return( mon_destroy( *mutex ) ); } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { return( mon_enter( *mutex ) ); } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { return( mon_exit( *mutex ) ); } int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) +ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mp ) { return( mon_cond_enter( *mp ) ); } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +ldap_int_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) { return( cv->lcv_created ? cv_destroy( cv->lcv_cv ) : 0 ); } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cv ) { return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 ); } diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c index 10782b0a48..14cdecb59e 100644 --- a/libraries/libldap_r/thr_nt.c +++ b/libraries/libldap_r/thr_nt.c @@ -15,39 +15,39 @@ #if defined( HAVE_NT_THREADS ) -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { return 0; } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { return 0; } int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)( void *), void *arg) { - *thread = (ldap_pvt_thread_t)_beginthread( (void *) start_routine, + *thread = (ldap_int_thread_t)_beginthread( (void *) start_routine, 0, arg ); return ( (unsigned long)*thread == -1 ? -1 : 0 ); } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { _endthread( ); } int -ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +ldap_int_thread_join( ldap_int_thread_t thread, void **thread_return ) { DWORD status; status = WaitForSingleObject( (HANDLE) thread, INFINITE ); @@ -58,42 +58,42 @@ ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { return 0; } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { Sleep( 0 ); return 0; } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { *cond = CreateEvent( NULL, FALSE, FALSE, NULL ); return( 0 ); } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +ldap_int_thread_cond_destroy( ldap_int_thread_cond_t *cv ) { CloseHandle( *cv ); return( 0 ); } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { SetEvent( *cond ); return( 0 ); } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { ReleaseMutex( *mutex ); SignalObjectAndWait( *mutex, *cond, INFINITE, FALSE ); @@ -102,42 +102,42 @@ ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cond ) { SetEvent( *cond ); return( 0 ); } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { *mutex = CreateMutex( NULL, 0, NULL ); return ( 0 ); } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { CloseHandle( *mutex ); return ( 0 ); } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { WaitForSingleObject( *mutex, INFINITE ); return ( 0 ); } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { ReleaseMutex( *mutex ); return ( 0 ); } int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) +ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mp ) { DWORD status; diff --git a/libraries/libldap_r/thr_posix.c b/libraries/libldap_r/thr_posix.c index 9d1e411ec3..b66cf7861c 100644 --- a/libraries/libldap_r/thr_posix.c +++ b/libraries/libldap_r/thr_posix.c @@ -18,7 +18,7 @@ #include -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" #if HAVE_PTHREADS_D4 @@ -33,23 +33,23 @@ int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { #if defined( LDAP_THREAD_CONCURRENCY ) && HAVE_PTHREAD_SETCONCURRENCY - ldap_pvt_thread_set_concurrency( LDAP_THREAD_CONCURRENCY ); + ldap_int_thread_set_concurrency( LDAP_THREAD_CONCURRENCY ); #endif return 0; } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { return 0; } #ifdef HAVE_PTHREAD_SETCONCURRENCY int -ldap_pvt_thread_set_concurrency(int n) +ldap_int_thread_set_concurrency(int n) { #ifdef HAVE_PTHREAD_SETCONCURRENCY return pthread_setconcurrency( n ); @@ -63,7 +63,7 @@ ldap_pvt_thread_set_concurrency(int n) #ifdef HAVE_PTHREAD_GETCONCURRENCY int -ldap_pvt_thread_get_concurrency(void) +ldap_int_thread_get_concurrency(void) { #ifdef HAVE_PTHREAD_GETCONCURRENCY return pthread_getconcurrency(); @@ -76,7 +76,7 @@ ldap_pvt_thread_get_concurrency(void) #endif int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)( void * ), void *arg) @@ -106,13 +106,13 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { pthread_exit( retval ); } int -ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +ldap_int_thread_join( ldap_int_thread_t thread, void **thread_return ) { #if !defined( HAVE_PTHREADS_FINAL ) void *dummy; @@ -123,7 +123,7 @@ ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { #ifdef HAVE_PTHREAD_KILL return pthread_kill( thread, signo ); @@ -136,7 +136,7 @@ ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { #ifdef _POSIX_THREAD_IS_GNU_PTH sched_yield(); @@ -158,62 +158,62 @@ ldap_pvt_thread_yield( void ) } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { return pthread_cond_init( cond, LDAP_PVT_THREAD_CONDATTR_DEFAULT ); } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_destroy( ldap_int_thread_cond_t *cond ) { return pthread_cond_destroy( cond ); } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { return pthread_cond_signal( cond ); } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cond ) { return pthread_cond_broadcast( cond ); } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { return pthread_cond_wait( cond, mutex ); } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { return pthread_mutex_init( mutex, LDAP_PVT_THREAD_MUTEXATTR_DEFAULT ); } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { return pthread_mutex_destroy( mutex ); } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { return pthread_mutex_lock( mutex ); } int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mutex ) { return pthread_mutex_trylock( mutex ); } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { return pthread_mutex_unlock( mutex ); } diff --git a/libraries/libldap_r/thr_pth.c b/libraries/libldap_r/thr_pth.c index 5017119d95..460dd8fee2 100644 --- a/libraries/libldap_r/thr_pth.c +++ b/libraries/libldap_r/thr_pth.c @@ -15,7 +15,7 @@ #if defined( HAVE_GNU_PTH ) -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" /******************* * * @@ -26,7 +26,7 @@ static pth_attr_t detach_attr; int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { detach_attr = pth_attr_new(); pth_attr_set( detach_attr, PTH_ATTR_JOINABLE, FALSE ); @@ -34,7 +34,7 @@ ldap_pvt_thread_initialize( void ) } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { pth_attr_destroy(detach_attr); pth_kill(); @@ -42,7 +42,7 @@ ldap_pvt_thread_destroy( void ) } int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)( void *), void *arg) @@ -54,88 +54,88 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { pth_exit( retval ); } -int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +int ldap_int_thread_join( ldap_int_thread_t thread, void **thread_return ) { pth_join( thread, thread_return ); return 0; } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { pth_raise( thread, signo ); return 0; } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { pth_yield(NULL); return 0; } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { return( pth_cond_init( cond ) ); } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { return( pth_cond_notify( cond, 0 ) ); } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cond ) { return( pth_cond_notify( cond, 1 ) ); } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { return( pth_cond_await( cond, mutex, NULL ) ); } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +ldap_int_thread_cond_destroy( ldap_int_thread_cond_t *cv ) { return 0; } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { return( pth_mutex_init( mutex ) ); } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { return 0; } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { return( pth_mutex_acquire( mutex, 0, NULL ) ); } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { return( pth_mutex_release( mutex ) ); } int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mutex ) { return( pth_mutex_acquire( mutex, 1, NULL ) ); } diff --git a/libraries/libldap_r/thr_stub.c b/libraries/libldap_r/thr_stub.c index ea71001d0c..c4dc6acdfd 100644 --- a/libraries/libldap_r/thr_stub.c +++ b/libraries/libldap_r/thr_stub.c @@ -15,7 +15,7 @@ #if defined( NO_THREADS ) -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" /*********************************************************************** * * @@ -25,13 +25,13 @@ ***********************************************************************/ int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { return 0; } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { return 0; } @@ -39,7 +39,7 @@ ldap_pvt_thread_destroy( void ) static void* ldap_int_status = NULL; int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)(void *), void *arg) @@ -50,7 +50,7 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { if( retval != NULL ) { ldap_int_status = retval; @@ -59,75 +59,75 @@ ldap_pvt_thread_exit( void *retval ) } int -ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status ) +ldap_int_thread_join( ldap_int_thread_t thread, void **status ) { if(status != NULL) *status = ldap_int_status; return 0; } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { return 0; } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { return 0; } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { return 0; } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_destroy( ldap_int_thread_cond_t *cond ) { return 0; } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { return 0; } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cond ) { return 0; } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { return 0; } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { return 0; } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { return 0; } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { return 0; } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { return 0; } diff --git a/libraries/libldap_r/thr_thr.c b/libraries/libldap_r/thr_thr.c index ee82993f50..949052a3fd 100644 --- a/libraries/libldap_r/thr_thr.c +++ b/libraries/libldap_r/thr_thr.c @@ -15,7 +15,7 @@ #if defined( HAVE_THR ) -#include "ldap_pvt_thread.h" +#include "ldap_int_thread.h" /******************* * * @@ -24,7 +24,7 @@ *******************/ int -ldap_pvt_thread_initialize( void ) +ldap_int_thread_initialize( void ) { #ifdef LDAP_THREAD_CONCURRENCY thr_setconcurrency( LDAP_THREAD_CONCURRENCY ); @@ -33,25 +33,25 @@ ldap_pvt_thread_initialize( void ) } int -ldap_pvt_thread_destroy( void ) +ldap_int_thread_destroy( void ) { return 0; } int -ldap_pvt_thread_set_concurrency(int n) +ldap_int_thread_set_concurrency(int n) { return thr_setconcurrency( n ); } int -ldap_pvt_thread_get_concurrency(void) +ldap_int_thread_get_concurrency(void) { return thr_getconcurrency(); } int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, +ldap_int_thread_create( ldap_int_thread_t * thread, int detach, void *(*start_routine)( void *), void *arg) @@ -62,88 +62,88 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, } void -ldap_pvt_thread_exit( void *retval ) +ldap_int_thread_exit( void *retval ) { thr_exit( NULL ); } -int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +int ldap_int_thread_join( ldap_int_thread_t thread, void **thread_return ) { thr_join( thread, NULL, thread_return ); return 0; } int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +ldap_int_thread_kill( ldap_int_thread_t thread, int signo ) { thr_kill( thread, signo ); return 0; } int -ldap_pvt_thread_yield( void ) +ldap_int_thread_yield( void ) { thr_yield(); return 0; } int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_init( ldap_int_thread_cond_t *cond ) { return( cond_init( cond, USYNC_THREAD, NULL ) ); } int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +ldap_int_thread_cond_signal( ldap_int_thread_cond_t *cond ) { return( cond_signal( cond ) ); } int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv ) +ldap_int_thread_cond_broadcast( ldap_int_thread_cond_t *cv ) { return( cond_broadcast( cv ) ); } int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_cond_wait( ldap_int_thread_cond_t *cond, + ldap_int_thread_mutex_t *mutex ) { return( cond_wait( cond, mutex ) ); } int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +ldap_int_thread_cond_destroy( ldap_int_thread_cond_t *cv ) { return( cond_destroy( cv ) ); } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_init( ldap_int_thread_mutex_t *mutex ) { return( mutex_init( mutex, USYNC_THREAD, NULL ) ); } int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_destroy( ldap_int_thread_mutex_t *mutex ) { return( mutex_destroy( mutex ) ); } int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_lock( ldap_int_thread_mutex_t *mutex ) { return( mutex_lock( mutex ) ); } int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) { return( mutex_unlock( mutex ) ); } int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) +ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mp ) { return( mutex_trylock( mp ) ); } diff --git a/libraries/libldap_r/threads.c b/libraries/libldap_r/threads.c new file mode 100644 index 0000000000..74ce67c2d3 --- /dev/null +++ b/libraries/libldap_r/threads.c @@ -0,0 +1,143 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include "ldap_int_thread.h" +#include "ldap_pvt_thread.h" + +LIBLDAP_F( int ) +ldap_pvt_thread_initialize ( void ) +{ + return ldap_int_thread_initialize(); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_destroy ( void ) +{ + return ldap_int_thread_destroy(); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_get_concurrency ( void ) +{ +#ifdef HAVE_GETCONCURRENCY + return ldap_int_thread_get_concurrency(); +#else + return 1; +#endif +} + +LIBLDAP_F( int ) +ldap_pvt_thread_set_concurrency ( int concurrency ) +{ +#ifdef HAVE_SETCONCURRENCY + return ldap_int_thread_set_concurrency(concurrency); +#else + return 1; +#endif +} + +LIBLDAP_F( int ) +ldap_pvt_thread_create ( + ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void * ), + void *arg) +{ + return ldap_int_thread_create(thread, detach, start_routine, arg); +} + +LIBLDAP_F( void ) +ldap_pvt_thread_exit ( void *retval ) +{ + ldap_int_thread_exit(retval); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_join ( ldap_pvt_thread_t thread, void **status ) +{ + return ldap_int_thread_join(thread, status); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_kill ( ldap_pvt_thread_t thread, int signo ) +{ + return ldap_int_thread_kill(thread, signo); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_yield ( void ) +{ + return ldap_int_thread_yield(); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_cond_init ( ldap_pvt_thread_cond_t *cond ) +{ + return ldap_int_thread_cond_init(cond); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_cond_destroy ( ldap_pvt_thread_cond_t *cond ) +{ + return ldap_int_thread_cond_destroy(cond); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_cond_signal ( ldap_pvt_thread_cond_t *cond ) +{ + return ldap_int_thread_cond_signal(cond); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_cond_broadcast ( ldap_pvt_thread_cond_t *cond ) +{ + return ldap_int_thread_cond_broadcast(cond); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_cond_wait ( + ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + return ldap_int_thread_cond_wait(cond, mutex); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_mutex_init ( ldap_pvt_thread_mutex_t *mutex ) +{ + return ldap_int_thread_mutex_init(mutex); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_mutex_destroy ( ldap_pvt_thread_mutex_t *mutex ) +{ + return ldap_int_thread_mutex_destroy(mutex); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_mutex_lock ( ldap_pvt_thread_mutex_t *mutex ) +{ + return ldap_int_thread_mutex_lock(mutex); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_mutex_trylock ( ldap_pvt_thread_mutex_t *mutex ) +{ + return ldap_int_thread_mutex_trylock(mutex); +} + +LIBLDAP_F( int ) +ldap_pvt_thread_mutex_unlock ( ldap_pvt_thread_mutex_t *mutex ) +{ + return ldap_int_thread_mutex_unlock(mutex); +}