Obtained from: FreeBSD ports
Acked-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/util/futex.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/util/futex.h b/src/util/futex.h
index 4402893069..425e34a2cd 100644
--- a/src/util/futex.h
+++ b/src/util/futex.h
@@ -51,6 +51,28 @@ static inline int futex_wait(uint32_t *addr, int32_t value, 
const struct timespe
                     FUTEX_BITSET_MATCH_ANY);
 }
 
+#elif defined(__FreeBSD__)
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/umtx.h>
+
+static inline int sys_futex(void *addr1, int op, int val1, const struct 
timespec *timeout, void *addr2, int _)
+{
+   return _umtx_op(addr1, op, (uint32_t)val1, addr2, (void*)timeout) == -1 ? 
errno : 0;
+}
+
+static inline int futex_wake(uint32_t *addr, int count)
+{
+   return sys_futex(addr, UMTX_OP_WAKE, count, NULL, NULL, 0);
+}
+
+static inline int futex_wait(uint32_t *addr, int32_t value, int32_t _)
+{
+   return sys_futex(addr, UMTX_OP_WAIT_UINT, value, NULL, NULL, 0);
+}
+
 #endif
 
 #endif /* UTIL_FUTEX_H */
-- 
2.15.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to