From 107e99e302a291fc938dc6206c09ae7802887c42 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 7 Jun 2000 01:34:00 +0000 Subject: [PATCH] Add Pth specific r/w lock implementation. --- include/ldap_int_thread.h | 3 +++ libraries/libldap_r/thr_pth.c | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/ldap_int_thread.h b/include/ldap_int_thread.h index 5da7f13c17..23cb1eb2a4 100644 --- a/include/ldap_int_thread.h +++ b/include/ldap_int_thread.h @@ -89,6 +89,9 @@ 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; +#define LDAP_THREAD_HAVE_RDWR 1 +typedef pth_rwlock_t ldap_pvt_thread_rdwr_t; + LDAP_END_DECL diff --git a/libraries/libldap_r/thr_pth.c b/libraries/libldap_r/thr_pth.c index 460dd8fee2..d35e485f27 100644 --- a/libraries/libldap_r/thr_pth.c +++ b/libraries/libldap_r/thr_pth.c @@ -140,4 +140,48 @@ ldap_int_thread_mutex_trylock( ldap_int_thread_mutex_t *mutex ) return( pth_mutex_acquire( mutex, 1, NULL ) ); } +#ifdef LDAP_THREAD_HAVE_RDWR +int +ldap_pvt_thread_rdwr_init( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_init( rw ); +} + +int +ldap_pvt_thread_rdwr_destroy( ldap_pvt_thread_rdwr_t *rw ) +{ + return 0; +} + +int ldap_pvt_thread_rdwr_rlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_acquire( rw, PTH_RWLOCK_RD, 0, NULL ); +} + +int ldap_pvt_thread_rdwr_rtrylock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_acquire( rw, PTH_RWLOCK_RD, 1, NULL ); +} + +int ldap_pvt_thread_rdwr_runlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_release( rw ); +} + +int ldap_pvt_thread_rdwr_wlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_acquire( rw, PTH_RWLOCK_RW, 0, NULL ); +} + +int ldap_pvt_thread_rdwr_wtrylock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_acquire( rw, PTH_RWLOCK_RW, 1, NULL ); +} + +int ldap_pvt_thread_rdwr_wunlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pth_rwlock_release( rw ); +} + +#endif /* LDAP_THREAD_HAVE_RDWR */ #endif /* HAVE_GNU_PTH */ -- 2.39.5