util: enable futex usage on BSDs after 7dc2f47882
Reviewed-by: Eric Engestrom <eric@engestrom.ch> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5460>
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#define UTIL_FUTEX_H
|
#define UTIL_FUTEX_H
|
||||||
|
|
||||||
#if defined(HAVE_LINUX_FUTEX_H)
|
#if defined(HAVE_LINUX_FUTEX_H)
|
||||||
|
#define UTIL_FUTEX_SUPPORTED 1
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.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__)
|
#elif defined(__FreeBSD__)
|
||||||
|
#define UTIL_FUTEX_SUPPORTED 1
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.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__)
|
#elif defined(__OpenBSD__)
|
||||||
|
#define UTIL_FUTEX_SUPPORTED 1
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/futex.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);
|
return futex(addr, FUTEX_WAIT, value, &tsrel, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define UTIL_FUTEX_SUPPORTED 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* UTIL_FUTEX_H */
|
#endif /* UTIL_FUTEX_H */
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "c11/threads.h"
|
#include "c11/threads.h"
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(HAVE_LINUX_FUTEX_H)
|
#if UTIL_FUTEX_SUPPORTED
|
||||||
|
|
||||||
/* mtx_t - Fast, simple mutex
|
/* mtx_t - Fast, simple mutex
|
||||||
*
|
*
|
||||||
|
@@ -50,7 +50,7 @@ extern "C" {
|
|||||||
#define UTIL_QUEUE_INIT_RESIZE_IF_FULL (1 << 1)
|
#define UTIL_QUEUE_INIT_RESIZE_IF_FULL (1 << 1)
|
||||||
#define UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY (1 << 2)
|
#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
|
#define UTIL_QUEUE_FENCE_FUTEX
|
||||||
#else
|
#else
|
||||||
#define UTIL_QUEUE_FENCE_STANDARD
|
#define UTIL_QUEUE_FENCE_STANDARD
|
||||||
|
Reference in New Issue
Block a user