diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-10-13 22:31:00 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-10-13 22:31:00 +0000 |
commit | 653013bedcf9edec36d71ef9ce4ccb82f17fb7f8 (patch) | |
tree | af37c7fb8d45dbc37e2edd0338eab2a3ac8ccd05 /lib/libthr | |
parent | a17c967b4268415a2e15e370462ebce4aa64cbf0 (diff) | |
download | FreeBSD-src-653013bedcf9edec36d71ef9ce4ccb82f17fb7f8.zip FreeBSD-src-653013bedcf9edec36d71ef9ce4ccb82f17fb7f8.tar.gz |
o Make _thr_umutex_init a function.
o Eliminate unused parameter for some functions.
o Convert type of first parameter to void * for _thr_umtx_wait
and _thr_umtx_wake.
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_umtx.c | 20 | ||||
-rw-r--r-- | lib/libthr/thread/thr_umtx.h | 24 |
2 files changed, 23 insertions, 21 deletions
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c index ec19ae9..cc3cb9d 100644 --- a/lib/libthr/thread/thr_umtx.c +++ b/lib/libthr/thread/thr_umtx.c @@ -30,8 +30,16 @@ #include "thr_private.h" #include "thr_umtx.h" +void +_thr_umutex_init(struct umutex *mtx) +{ + static struct umutex default_mtx = DEFAULT_UMUTEX; + + *mtx = default_mtx; +} + int -__thr_umutex_lock(struct umutex *mtx, uint32_t id) +__thr_umutex_lock(struct umutex *mtx) { if (_umtx_op(mtx, UMTX_OP_MUTEX_LOCK, 0, 0, 0) == 0) return 0; @@ -39,7 +47,7 @@ __thr_umutex_lock(struct umutex *mtx, uint32_t id) } int -__thr_umutex_timedlock(struct umutex *mtx, uint32_t id, +__thr_umutex_timedlock(struct umutex *mtx, const struct timespec *timeout) { if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && @@ -52,7 +60,7 @@ __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, } int -__thr_umutex_unlock(struct umutex *mtx, uint32_t id) +__thr_umutex_unlock(struct umutex *mtx) { if (_umtx_op(mtx, UMTX_OP_MUTEX_UNLOCK, 0, 0, 0) == 0) return (0); @@ -60,7 +68,7 @@ __thr_umutex_unlock(struct umutex *mtx, uint32_t id) } int -__thr_umutex_kern_trylock(struct umutex *mtx) +__thr_umutex_trylock(struct umutex *mtx) { if (_umtx_op(mtx, UMTX_OP_MUTEX_TRYLOCK, 0, 0, 0) == 0) return (0); @@ -82,7 +90,7 @@ _thr_umtx_wait(volatile umtx_t *mtx, long 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(struct umtx *, mtx), UMTX_OP_WAIT, id, 0, + if (_umtx_op(__DEVOLATILE(void *, mtx), UMTX_OP_WAIT, id, 0, __DECONST(void*, timeout)) == 0) return (0); return (errno); @@ -91,7 +99,7 @@ _thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout) int _thr_umtx_wake(volatile umtx_t *mtx, int nr_wakeup) { - if (_umtx_op(__DEVOLATILE(struct umtx *, mtx), UMTX_OP_WAKE, + if (_umtx_op(__DEVOLATILE(void *, mtx), UMTX_OP_WAKE, nr_wakeup, 0, 0) == 0) return (0); return (errno); diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h index de958ee..4f7c06b 100644 --- a/lib/libthr/thread/thr_umtx.h +++ b/lib/libthr/thread/thr_umtx.h @@ -36,25 +36,19 @@ typedef long umtx_t; -int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden; -int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, +int __thr_umutex_lock(struct umutex *mtx) __hidden; +int __thr_umutex_timedlock(struct umutex *mtx, const struct timespec *timeout) __hidden; -int __thr_umutex_unlock(struct umutex *mtx, uint32_t id) __hidden; -int __thr_umutex_kern_trylock(struct umutex *mtx) __hidden; +int __thr_umutex_unlock(struct umutex *mtx) __hidden; +int __thr_umutex_trylock(struct umutex *mtx) __hidden; 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, const struct timespec *timeout) __hidden; int _thr_umtx_wake(volatile umtx_t *mtx, int count) __hidden; -static inline void -_thr_umutex_init(struct umutex *mtx) -{ - struct umutex tmp = DEFAULT_UMUTEX; - *mtx = tmp; -} - static inline int _thr_umutex_trylock(struct umutex *mtx, uint32_t id) { @@ -62,7 +56,7 @@ _thr_umutex_trylock(struct umutex *mtx, uint32_t id) return (0); if ((mtx->m_flags & UMUTEX_PRIO_PROTECT) == 0) return (EBUSY); - return (__thr_umutex_kern_trylock(mtx)); + return (__thr_umutex_trylock(mtx)); } static inline int @@ -70,7 +64,7 @@ _thr_umutex_lock(struct umutex *mtx, uint32_t id) { if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_UNOWNED, id)) return (0); - return (__thr_umutex_lock(mtx, id)); + return (__thr_umutex_lock(mtx)); } static inline int @@ -79,7 +73,7 @@ _thr_umutex_timedlock(struct umutex *mtx, uint32_t id, { if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_UNOWNED, id)) return (0); - return (__thr_umutex_timedlock(mtx, id, timeout)); + return (__thr_umutex_timedlock(mtx, timeout)); } static inline int @@ -87,7 +81,7 @@ _thr_umutex_unlock(struct umutex *mtx, uint32_t id) { if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED)) return (0); - return (__thr_umutex_unlock(mtx, id)); + return (__thr_umutex_unlock(mtx)); } #endif |