Mesa (master): util: enable futex usage on BSDs after 7dc2f4788288

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 16 22:08:23 UTC 2020


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

Author: Jan Beich <jbeich at FreeBSD.org>
Date:   Tue Jun  2 00:28:09 2020 +0000

util: enable futex usage on BSDs after 7dc2f4788288

Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5460>

---

 src/util/futex.h      | 5 +++++
 src/util/simple_mtx.h | 2 +-
 src/util/u_queue.h    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/util/futex.h b/src/util/futex.h
index cf8dd0206c9..4d712e2ef2d 100644
--- a/src/util/futex.h
+++ b/src/util/futex.h
@@ -25,6 +25,7 @@
 #define UTIL_FUTEX_H
 
 #if defined(HAVE_LINUX_FUTEX_H)
+#define UTIL_FUTEX_SUPPORTED 1
 
 #include <limits.h>
 #include <stdint.h>
@@ -52,6 +53,7 @@ static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespe
 }
 
 #elif defined(__FreeBSD__)
+#define UTIL_FUTEX_SUPPORTED 1
 
 #include <assert.h>
 #include <errno.h>
@@ -86,6 +88,7 @@ static inline int futex_wait(uint32_t *addr, int32_t value, struct timespec *tim
 }
 
 #elif defined(__OpenBSD__)
+#define UTIL_FUTEX_SUPPORTED 1
 
 #include <sys/time.h>
 #include <sys/futex.h>
@@ -103,6 +106,8 @@ static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespe
    return futex(addr, FUTEX_WAIT, value, &tsrel, NULL);
 }
 
+#else
+#define UTIL_FUTEX_SUPPORTED 0
 #endif
 
 #endif /* UTIL_FUTEX_H */
diff --git a/src/util/simple_mtx.h b/src/util/simple_mtx.h
index ec3889497f3..1bd57ac8001 100644
--- a/src/util/simple_mtx.h
+++ b/src/util/simple_mtx.h
@@ -29,7 +29,7 @@
 
 #include "c11/threads.h"
 
-#if defined(__GNUC__) && defined(HAVE_LINUX_FUTEX_H)
+#if UTIL_FUTEX_SUPPORTED
 
 /* mtx_t - Fast, simple mutex
  *
diff --git a/src/util/u_queue.h b/src/util/u_queue.h
index 9666fd9c4b5..5943df4fcbb 100644
--- a/src/util/u_queue.h
+++ b/src/util/u_queue.h
@@ -50,7 +50,7 @@ extern "C" {
 #define UTIL_QUEUE_INIT_RESIZE_IF_FULL            (1 << 1)
 #define UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY  (1 << 2)
 
-#if defined(__GNUC__) && defined(HAVE_LINUX_FUTEX_H)
+#if UTIL_FUTEX_SUPPORTED
 #define UTIL_QUEUE_FENCE_FUTEX
 #else
 #define UTIL_QUEUE_FENCE_STANDARD



More information about the mesa-commit mailing list