aboutsummaryrefslogtreecommitdiff
path: root/lib/libthr
diff options
context:
space:
mode:
authorDavid Xu <davidxu@FreeBSD.org>2005-07-28 03:34:54 +0000
committerDavid Xu <davidxu@FreeBSD.org>2005-07-28 03:34:54 +0000
commit2ff77b92202abdf10ab3f2434ac25719083ebeeb (patch)
tree669f2101edbca78d0edd5280130f7e22b2e8191f /lib/libthr
parente33ed6289eec1d25aec067a112339e0752bdaca5 (diff)
Notes
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_umtx.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h
index 4ccfb69c6ed2..8d2718dc47f5 100644
--- a/lib/libthr/thread/thr_umtx.h
+++ b/lib/libthr/thread/thr_umtx.h
@@ -47,30 +47,36 @@ _thr_umtx_init(volatile umtx_t *mtx)
static inline int
_thr_umtx_trylock(volatile umtx_t *mtx, long id)
{
- return umtx_trylock((struct umtx *)mtx, id);
+ if (atomic_cmpset_acq_ptr((volatile uintptr_t *)mtx,
+ (uintptr_t)UMTX_UNOWNED, (uintptr_t)id))
+ return (0);
+ return (EBUSY);
}
static inline int
_thr_umtx_lock(volatile umtx_t *mtx, long id)
{
- if (atomic_cmpset_acq_ptr(mtx, (void *)UMTX_UNOWNED, (void *)id))
+ if (atomic_cmpset_acq_ptr((volatile uintptr_t *)mtx,
+ (uintptr_t)UMTX_UNOWNED, (uintptr_t)id))
return (0);
- return __thr_umtx_lock(mtx, id);
+ return (__thr_umtx_lock(mtx, id));
}
static inline int
_thr_umtx_timedlock(volatile umtx_t *mtx, long id,
const struct timespec *timeout)
{
- if (atomic_cmpset_acq_ptr(mtx, (void *)UMTX_UNOWNED, (void *)id))
+ if (atomic_cmpset_acq_ptr((volatile uintptr_t *)mtx,
+ (uintptr_t)UMTX_UNOWNED, (uintptr_t)id))
return (0);
- return __thr_umtx_timedlock(mtx, id, timeout);
+ return (__thr_umtx_timedlock(mtx, id, timeout));
}
static inline int
_thr_umtx_unlock(volatile umtx_t *mtx, long id)
{
- if (atomic_cmpset_rel_ptr(mtx, (void *)id, (void *)UMTX_UNOWNED))
+ if (atomic_cmpset_rel_ptr((volatile uintptr_t *)mtx,
+ (uintptr_t)id, (uintptr_t)UMTX_UNOWNED))
return (0);
return __thr_umtx_unlock(mtx, id);
}