From 2a76d14fc7b2db2bed221ea6782d08129e7f7ec3 Mon Sep 17 00:00:00 2001 From: davidxu Date: Sat, 28 Jun 2003 09:47:22 +0000 Subject: Temporary disable rwlock based code, replace it with low level KSE locking code until rtld-elf and libkse can cooperate better, those code can be restored. Reviewed by: deischen --- lib/libkse/thread/thr_rtld.c | 92 ++++++++++++++++++++++++++++++++++++++++ lib/libpthread/thread/thr_rtld.c | 92 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) diff --git a/lib/libkse/thread/thr_rtld.c b/lib/libkse/thread/thr_rtld.c index c1ee77e..b7043d0 100644 --- a/lib/libkse/thread/thr_rtld.c +++ b/lib/libkse/thread/thr_rtld.c @@ -28,6 +28,7 @@ * $FreeBSD$ */ #include +#include #include #include "thr_private.h" @@ -39,6 +40,7 @@ static void _thr_rtld_lock_release(void *); static int _thr_rtld_set_flag(int); static int _thr_rtld_clr_flag(int); +#ifdef NOTYET static void * _thr_rtld_lock_create() { @@ -135,3 +137,93 @@ _thr_rtld_fini() { _rtld_thread_init(NULL); } +#endif + +struct rtld_kse_lock { + struct lock lck; + kse_critical_t crit; +}; + +static void * +_thr_rtld_lock_create() +{ + struct rtld_kse_lock *l = malloc(sizeof(struct rtld_kse_lock)); + + _lock_init(&l->lck, LCK_ADAPTIVE, _kse_lock_wait, _kse_lock_wakeup); + return (l); +} + +static void +_thr_rtld_lock_destroy(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + + _lock_destroy(&l->lck); + free(l); +} + +static void +_thr_rtld_rlock_acquire(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + kse_critical_t crit; + + crit = _kse_critical_enter(); + KSE_LOCK_ACQUIRE(_get_curkse(), &l->lck); + l->crit = crit; +} + +static void +_thr_rtld_wlock_acquire(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + kse_critical_t crit; + + crit = _kse_critical_enter(); + KSE_LOCK_ACQUIRE(_get_curkse(), &l->lck); + l->crit = crit; +} + +static void +_thr_rtld_lock_release(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + kse_critical_t crit = l->crit; + + KSE_LOCK_RELEASE(_get_curkse(), &l->lck); + _kse_critical_leave(crit); +} + + +static int +_thr_rtld_set_flag(int mask) +{ + return (0); +} + +static int +_thr_rtld_clr_flag(int mask) +{ + return (0); +} + +void +_thr_rtld_init() +{ + struct RtldLockInfo li; + li.lock_create = _thr_rtld_lock_create; + li.lock_destroy = _thr_rtld_lock_destroy; + li.rlock_acquire = _thr_rtld_rlock_acquire; + li.wlock_acquire = _thr_rtld_wlock_acquire; + li.lock_release = _thr_rtld_lock_release; + li.thread_set_flag = _thr_rtld_set_flag; + li.thread_clr_flag = _thr_rtld_clr_flag; + li.at_fork = NULL; + _rtld_thread_init(&li); +} + +void +_thr_rtld_fini() +{ + _rtld_thread_init(NULL); +} diff --git a/lib/libpthread/thread/thr_rtld.c b/lib/libpthread/thread/thr_rtld.c index c1ee77e..b7043d0 100644 --- a/lib/libpthread/thread/thr_rtld.c +++ b/lib/libpthread/thread/thr_rtld.c @@ -28,6 +28,7 @@ * $FreeBSD$ */ #include +#include #include #include "thr_private.h" @@ -39,6 +40,7 @@ static void _thr_rtld_lock_release(void *); static int _thr_rtld_set_flag(int); static int _thr_rtld_clr_flag(int); +#ifdef NOTYET static void * _thr_rtld_lock_create() { @@ -135,3 +137,93 @@ _thr_rtld_fini() { _rtld_thread_init(NULL); } +#endif + +struct rtld_kse_lock { + struct lock lck; + kse_critical_t crit; +}; + +static void * +_thr_rtld_lock_create() +{ + struct rtld_kse_lock *l = malloc(sizeof(struct rtld_kse_lock)); + + _lock_init(&l->lck, LCK_ADAPTIVE, _kse_lock_wait, _kse_lock_wakeup); + return (l); +} + +static void +_thr_rtld_lock_destroy(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + + _lock_destroy(&l->lck); + free(l); +} + +static void +_thr_rtld_rlock_acquire(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + kse_critical_t crit; + + crit = _kse_critical_enter(); + KSE_LOCK_ACQUIRE(_get_curkse(), &l->lck); + l->crit = crit; +} + +static void +_thr_rtld_wlock_acquire(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + kse_critical_t crit; + + crit = _kse_critical_enter(); + KSE_LOCK_ACQUIRE(_get_curkse(), &l->lck); + l->crit = crit; +} + +static void +_thr_rtld_lock_release(void *lock) +{ + struct rtld_kse_lock *l = (struct rtld_kse_lock *)lock; + kse_critical_t crit = l->crit; + + KSE_LOCK_RELEASE(_get_curkse(), &l->lck); + _kse_critical_leave(crit); +} + + +static int +_thr_rtld_set_flag(int mask) +{ + return (0); +} + +static int +_thr_rtld_clr_flag(int mask) +{ + return (0); +} + +void +_thr_rtld_init() +{ + struct RtldLockInfo li; + li.lock_create = _thr_rtld_lock_create; + li.lock_destroy = _thr_rtld_lock_destroy; + li.rlock_acquire = _thr_rtld_rlock_acquire; + li.wlock_acquire = _thr_rtld_wlock_acquire; + li.lock_release = _thr_rtld_lock_release; + li.thread_set_flag = _thr_rtld_set_flag; + li.thread_clr_flag = _thr_rtld_clr_flag; + li.at_fork = NULL; + _rtld_thread_init(&li); +} + +void +_thr_rtld_fini() +{ + _rtld_thread_init(NULL); +} -- cgit v1.1