From 46c368907fcf333a19881d28c46e997845d00faf Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 2 Jun 2020 00:28:09 +0000 Subject: [PATCH] util: enable futex usage on BSDs after 7dc2f4788288 Reviewed-by: Eric Engestrom Cc: mesa-stable Part-of: --- 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 #include @@ -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 #include @@ -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 #include @@ -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 -- 2.30.2