Mesa (master): util/futex: use futex syscall on OpenBSD

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 2 22:26:03 UTC 2019


Module: Mesa
Branch: master
Commit: c91997b6c4395831a8de2b84e6ea2ff981a00e4b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c91997b6c4395831a8de2b84e6ea2ff981a00e4b

Author: Jonathan Gray <jsg at jsg.id.au>
Date:   Sun Dec  1 02:19:38 2019 +1100

util/futex: use futex syscall on OpenBSD

Make use of the futex syscall added in OpenBSD 6.2.

Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
Signed-off-by: Marek Olšák <marek.olsak at amd.com>

---

 src/util/futex.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/util/futex.h b/src/util/futex.h
index 268af92882a..cf8dd0206c9 100644
--- a/src/util/futex.h
+++ b/src/util/futex.h
@@ -85,6 +85,24 @@ static inline int futex_wait(uint32_t *addr, int32_t value, struct timespec *tim
    return _umtx_op(addr, UMTX_OP_WAIT_UINT, (uint32_t)value, uaddr, uaddr2) == -1 ? errno : 0;
 }
 
+#elif defined(__OpenBSD__)
+
+#include <sys/time.h>
+#include <sys/futex.h>
+
+static inline int futex_wake(uint32_t *addr, int count)
+{
+   return futex(addr, FUTEX_WAKE, count, NULL, NULL);
+}
+
+static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespec *timeout)
+{
+   struct timespec tsrel, tsnow;
+   clock_gettime(CLOCK_MONOTONIC, &tsnow); 
+   timespecsub(timeout, &tsrel, &tsrel);
+   return futex(addr, FUTEX_WAIT, value, &tsrel, NULL);
+}
+
 #endif
 
 #endif /* UTIL_FUTEX_H */




More information about the mesa-commit mailing list