summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_umtx.h
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2006-09-06 04:04:10 +0000
committerdavidxu <davidxu@FreeBSD.org>2006-09-06 04:04:10 +0000
commit21e453602609114dd397ffe11541b88ac47cbde4 (patch)
tree7044b040d8f18506b5f3294848fd18b67eaf0bd2 /lib/libthr/thread/thr_umtx.h
parent670deaece645da636be8d143eb99b79497386ec3 (diff)
downloadFreeBSD-src-21e453602609114dd397ffe11541b88ac47cbde4.zip
FreeBSD-src-21e453602609114dd397ffe11541b88ac47cbde4.tar.gz
Replace internal usage of struct umtx with umutex which can supports
real-time if we want, no functionality is changed.
Diffstat (limited to 'lib/libthr/thread/thr_umtx.h')
-rw-r--r--lib/libthr/thread/thr_umtx.h60
1 files changed, 10 insertions, 50 deletions
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h
index 5b62e88..de958ee 100644
--- a/lib/libthr/thread/thr_umtx.h
+++ b/lib/libthr/thread/thr_umtx.h
@@ -29,17 +29,13 @@
#ifndef _THR_FBSD_UMTX_H_
#define _THR_FBSD_UMTX_H_
+#include <strings.h>
#include <sys/umtx.h>
-typedef long umtx_t;
+#define DEFAULT_UMUTEX {0, 0, {0, 0}, {0, 0, 0, 0}}
-/* simple lock routines.*/
-int __thr_umtx_lock(volatile umtx_t *mtx, long id) __hidden;
-int __thr_umtx_timedlock(volatile umtx_t *mtx, long id,
- const struct timespec *timeout) __hidden;
-int __thr_umtx_unlock(volatile umtx_t *mtx, long id) __hidden;
+typedef long umtx_t;
-/* POSIX semantic lock routines */
int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden;
int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
const struct timespec *timeout) __hidden;
@@ -48,53 +44,17 @@ int __thr_umutex_kern_trylock(struct umutex *mtx) __hidden;
int __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling,
uint32_t *oldceiling) __hidden;
-static inline void
-_thr_umtx_init(volatile umtx_t *mtx)
-{
- *mtx = 0;
-}
-
-static inline int
-_thr_umtx_trylock(volatile umtx_t *mtx, long 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((volatile uintptr_t *)mtx,
- (uintptr_t)UMTX_UNOWNED, (uintptr_t)id))
- return (0);
- 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((volatile uintptr_t *)mtx,
- (uintptr_t)UMTX_UNOWNED, (uintptr_t)id))
- return (0);
- return (__thr_umtx_timedlock(mtx, id, timeout));
-}
-
-static inline int
-_thr_umtx_unlock(volatile umtx_t *mtx, long id)
-{
- if (atomic_cmpset_rel_ptr((volatile uintptr_t *)mtx,
- (uintptr_t)id, (uintptr_t)UMTX_UNOWNED))
- return (0);
- return __thr_umtx_unlock(mtx, id);
-}
-
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)
{
OpenPOWER on IntegriCloud