From c63688968a333b863524a975289bc95c25685608 Mon Sep 17 00:00:00 2001 From: davidxu Date: Wed, 21 Nov 2007 05:21:58 +0000 Subject: Remove umtx_t definition, use type long directly, add wrapper function _thr_umtx_wait_uint() for umtx operation UMTX_OP_WAIT_UINT, use the function in semaphore operations, this fixed compiler warnings. --- lib/libthr/thread/thr_private.h | 2 +- lib/libthr/thread/thr_rtld.c | 10 +++++----- lib/libthr/thread/thr_sem.c | 6 +++--- lib/libthr/thread/thr_sig.c | 3 ++- lib/libthr/thread/thr_suspend_np.c | 2 +- lib/libthr/thread/thr_umtx.c | 16 ++++++++++++++-- lib/libthr/thread/thr_umtx.h | 10 +++++----- 7 files changed, 31 insertions(+), 18 deletions(-) (limited to 'lib/libthr') diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index 313074f..abde74f 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -312,7 +312,7 @@ struct pthread { struct umutex lock; /* Internal condition variable cycle number. */ - umtx_t cycle; + long cycle; /* How many low level locks the thread held. */ int locklevel; diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c index 827b962..14fb127 100644 --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -52,8 +52,8 @@ struct rtld_lock { volatile int lock; volatile int rd_waiters; volatile int wr_waiters; - volatile umtx_t rd_cv; - volatile umtx_t wr_cv; + volatile long rd_cv; + volatile long wr_cv; void *base; }; @@ -93,7 +93,7 @@ _thr_rtld_rlock_acquire(void *lock) { struct pthread *curthread; struct rtld_lock *l; - umtx_t v; + long v; curthread = _get_curthread(); l = (struct rtld_lock *)lock; @@ -116,7 +116,7 @@ _thr_rtld_wlock_acquire(void *lock) { struct pthread *curthread; struct rtld_lock *l; - umtx_t v; + long v; curthread = _get_curthread(); l = (struct rtld_lock *)lock; @@ -185,7 +185,7 @@ _thr_rtld_init(void) { struct RtldLockInfo li; struct pthread *curthread; - umtx_t dummy; + long dummy; curthread = _get_curthread(); diff --git a/lib/libthr/thread/thr_sem.c b/lib/libthr/thread/thr_sem.c index 6dbf7f4..01557f3 100644 --- a/lib/libthr/thread/thr_sem.c +++ b/lib/libthr/thread/thr_sem.c @@ -196,7 +196,7 @@ _sem_wait(sem_t *sem) return (0); } _thr_cancel_enter(curthread); - retval = _thr_umtx_wait((umtx_t *)&(*sem)->count, 0, NULL); + retval = _thr_umtx_wait_uint(&(*sem)->count, 0, NULL); _thr_cancel_leave(curthread); } while (retval == 0); errno = retval; @@ -239,7 +239,7 @@ _sem_timedwait(sem_t * __restrict sem, clock_gettime(CLOCK_REALTIME, &ts); TIMESPEC_SUB(&ts2, abstime, &ts); _thr_cancel_enter(curthread); - retval = _thr_umtx_wait((umtx_t *)&(*sem)->count, 0, &ts2); + retval = _thr_umtx_wait_uint(&(*sem)->count, 0, &ts2); _thr_cancel_leave(curthread); } while (retval == 0); errno = retval; @@ -264,7 +264,7 @@ _sem_post(sem_t *sem) do { val = (*sem)->count; } while (!atomic_cmpset_acq_int(&(*sem)->count, val, val + 1)); - retval = _thr_umtx_wake((umtx_t *)&(*sem)->count, val + 1); + retval = _thr_umtx_wake(&(*sem)->count, val + 1); if (retval > 0) retval = 0; return (retval); diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c index 1be544b..8f3b055 100644 --- a/lib/libthr/thread/thr_sig.c +++ b/lib/libthr/thread/thr_sig.c @@ -55,6 +55,7 @@ int __sigtimedwait(const sigset_t *set, siginfo_t *info, int __sigwaitinfo(const sigset_t *set, siginfo_t *info); int __sigwait(const sigset_t *set, int *sig); + static void sigcancel_handler(int sig __unused, siginfo_t *info __unused, ucontext_t *ucp __unused) @@ -81,7 +82,7 @@ _thr_ast(struct pthread *curthread) void _thr_suspend_check(struct pthread *curthread) { - umtx_t cycle; + long cycle; int err; err = errno; diff --git a/lib/libthr/thread/thr_suspend_np.c b/lib/libthr/thread/thr_suspend_np.c index d5fb3b0..3e48656 100644 --- a/lib/libthr/thread/thr_suspend_np.c +++ b/lib/libthr/thread/thr_suspend_np.c @@ -121,7 +121,7 @@ static int suspend_common(struct pthread *curthread, struct pthread *thread, int waitok) { - umtx_t tmp; + long tmp; while (thread->state != PS_DEAD && !(thread->flags & THR_FLAGS_SUSPENDED)) { diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c index 0a5ee6a..058205b 100644 --- a/lib/libthr/thread/thr_umtx.c +++ b/lib/libthr/thread/thr_umtx.c @@ -85,7 +85,7 @@ __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling, } int -_thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout) +_thr_umtx_wait(volatile long *mtx, long id, const struct timespec *timeout) { if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && timeout->tv_nsec <= 0))) @@ -97,7 +97,19 @@ _thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout) } int -_thr_umtx_wake(volatile umtx_t *mtx, int nr_wakeup) +_thr_umtx_wait_uint(volatile u_int *mtx, u_int id, const struct timespec *timeout) +{ + if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && + timeout->tv_nsec <= 0))) + return (ETIMEDOUT); + if (_umtx_op(__DEVOLATILE(void *, mtx), UMTX_OP_WAIT_UINT, id, 0, + __DECONST(void*, timeout)) != -1) + return (0); + return (errno); +} + +int +_thr_umtx_wake(volatile void *mtx, int nr_wakeup) { if (_umtx_op(__DEVOLATILE(void *, mtx), UMTX_OP_WAKE, nr_wakeup, 0, 0) != -1) diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h index 1a60c1a..65d00f2 100644 --- a/lib/libthr/thread/thr_umtx.h +++ b/lib/libthr/thread/thr_umtx.h @@ -32,9 +32,7 @@ #include #include -#define DEFAULT_UMUTEX {0} - -typedef long umtx_t; +#define DEFAULT_UMUTEX {0,0, {0,0},{0,0,0,0}} int __thr_umutex_lock(struct umutex *mtx) __hidden; int __thr_umutex_timedlock(struct umutex *mtx, @@ -45,9 +43,11 @@ int __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling, uint32_t *oldceiling) __hidden; void _thr_umutex_init(struct umutex *mtx) __hidden; -int _thr_umtx_wait(volatile umtx_t *mtx, umtx_t exp, +int _thr_umtx_wait(volatile long *mtx, long exp, + const struct timespec *timeout) __hidden; +int _thr_umtx_wait_uint(volatile u_int *mtx, u_int exp, const struct timespec *timeout) __hidden; -int _thr_umtx_wake(volatile umtx_t *mtx, int count) __hidden; +int _thr_umtx_wake(volatile void *mtx, int count) __hidden; int _thr_ucond_wait(struct ucond *cv, struct umutex *m, const struct timespec *timeout, int check_unpaking) __hidden; void _thr_ucond_init(struct ucond *cv) __hidden; -- cgit v1.1