summaryrefslogtreecommitdiff
path: root/lib/mesa
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-02-27 13:09:01 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-02-27 13:09:01 +0000
commit21bd9a3db87fad3596e91fdc68324d90edcebdda (patch)
treefa13f359f0e7cd07a02c65fdff4f700ca3beb1d6 /lib/mesa
parent54ace44f26dab8031c5bb757158e1d984d3ccefe (diff)
util: enable futex usage on BSDs after 7dc2f4788288
From Jan Beich 46c368907fcf333a19881d28c46e997845d00faf in mainline Mesa We had a related local patch in 19.2 which wasn't needed when 20.1 was imported as the above commit was backported to the upstream 20.1 branch. When Mesa 20.0 was imported after issues with 20.1 on Haswell the changes to use futexes for simple_mtx.h and u_queue.h were lost. Noticed by otto@ and kettenis@ when looking for memory leaks.
Diffstat (limited to 'lib/mesa')
-rw-r--r--lib/mesa/src/util/futex.h5
-rw-r--r--lib/mesa/src/util/simple_mtx.h2
-rw-r--r--lib/mesa/src/util/u_queue.h2
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/mesa/src/util/futex.h b/lib/mesa/src/util/futex.h
index 57974df7d..43097f4cd 100644
--- a/lib/mesa/src/util/futex.h
+++ b/lib/mesa/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>
@@ -110,6 +113,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/lib/mesa/src/util/simple_mtx.h b/lib/mesa/src/util/simple_mtx.h
index 4fc8a0d4d..e332816b9 100644
--- a/lib/mesa/src/util/simple_mtx.h
+++ b/lib/mesa/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/lib/mesa/src/util/u_queue.h b/lib/mesa/src/util/u_queue.h
index 9666fd9c4..5943df4fc 100644
--- a/lib/mesa/src/util/u_queue.h
+++ b/lib/mesa/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