Changeset View
Changeset View
Standalone View
Standalone View
head/graphics/mesa-dri/files/patch-src_util_futex.h
- Implement futex_wake() and futex_wait() via _umtx_op() | - Implement futex_wake() and futex_wait() via _umtx_op() | ||||
--- src/util/futex.h.orig 2018-01-23 18:08:50 UTC | --- src/util/futex.h.orig 2018-09-24 16:00:57 UTC | ||||
+++ src/util/futex.h | +++ src/util/futex.h | ||||
@@ -29,10 +29,35 @@ | @@ -29,10 +29,32 @@ | ||||
#include <limits.h> | #include <limits.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
+#if defined(__FreeBSD__) | +#if defined(__FreeBSD__) | ||||
+#include <errno.h> | +#include <errno.h> | ||||
+# if __FreeBSD__ < 11 | |||||
+# include <machine/atomic.h> | |||||
+# endif | |||||
+#include <sys/umtx.h> | +#include <sys/umtx.h> | ||||
+#else | +#else | ||||
#include <linux/futex.h> | #include <linux/futex.h> | ||||
#include <sys/syscall.h> | #include <sys/syscall.h> | ||||
+#endif | +#endif | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
+#if defined(__FreeBSD__) | +#if defined(__FreeBSD__) | ||||
Show All 11 Lines | |||||
+ uaddr2 = (void *)&tmo; | + uaddr2 = (void *)&tmo; | ||||
+ } | + } | ||||
+ return _umtx_op(addr, UMTX_OP_WAIT_UINT, (uint32_t)value, uaddr, uaddr2) == -1 ? errno : 0; | + return _umtx_op(addr, UMTX_OP_WAIT_UINT, (uint32_t)value, uaddr, uaddr2) == -1 ? errno : 0; | ||||
+} | +} | ||||
+#else | +#else | ||||
static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3) | static inline long sys_futex(void *addr1, int op, int val1, const struct timespec *timeout, void *addr2, int val3) | ||||
{ | { | ||||
return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); | return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); | ||||
@@ -50,6 +75,7 @@ static inline int futex_wait(uint32_t *addr, int32_t v | @@ -50,6 +72,7 @@ static inline int futex_wait(uint32_t *addr, int32_t v | ||||
return sys_futex(addr, FUTEX_WAIT_BITSET, value, timeout, NULL, | return sys_futex(addr, FUTEX_WAIT_BITSET, value, timeout, NULL, | ||||
FUTEX_BITSET_MATCH_ANY); | FUTEX_BITSET_MATCH_ANY); | ||||
} | } | ||||
+#endif | +#endif | ||||
#endif | #endif | ||||