[lttng-dev] [PATCH 2/2] Use _umtx_op for futex on FreeBSD
Alex Xu (Hello71)
alex_y_xu at yahoo.ca
Mon Jan 27 13:25:26 EST 2020
---
include/urcu/futex.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/include/urcu/futex.h b/include/urcu/futex.h
index c206c6f..33dc3db 100644
--- a/include/urcu/futex.h
+++ b/include/urcu/futex.h
@@ -24,6 +24,7 @@
*/
#include <urcu/config.h>
+#include <errno.h>
#include <stdint.h>
#include <time.h>
@@ -103,6 +104,28 @@ static inline int futex_async(int32_t *uaddr, int op, int32_t val,
return ret;
}
+#elif defined(__FreeBSD__)
+
+#include <sys/umtx.h>
+
+static inline int futex_noasync(int32_t *uaddr, int op, int32_t val,
+ const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
+{
+ return futex_async(uaddr, op, val, timeout, uaddr2, val3);
+}
+
+static inline int futex_async(int32_t *uaddr, int op, int32_t val,
+ const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
+{
+ switch (op) {
+ case FUTEX_WAIT: op = UMTX_OP_WAIT_UINT; break;
+ case FUTEX_WAKE: op = UMTX_OP_WAKE; break;
+ default: errno = EINVAL; return -1;
+ }
+ return _umtx_op(uaddr, op, val,
+ (void *)sizeof(*timeout), (void *)timeout);
+}
+
#elif defined(__CYGWIN__)
/*
--
2.25.0
More information about the lttng-dev
mailing list