Add OpenBSD support using process-global futexes.

ok matthieu@
This commit is contained in:
kettenis 2018-06-08 13:16:24 +00:00
parent d9fb28853a
commit 3a5dfaa265
3 changed files with 36 additions and 1 deletions

View File

@ -17878,6 +17878,20 @@ fi
fi
if test "x$FUTEX" = "xauto"; then
ac_fn_c_check_header_mongrel "$LINENO" "sys/futex.h" "ac_cv_header_sys_futex_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_futex_h" = xyes; then :
FUTEX=yes
fi
if test "x$FUTEX" = "xyes"; then
$as_echo "#define HAVE_FUTEX 1" >>confdefs.h
fi
fi
if test "x$FUTEX" = "xauto"; then
ac_fn_c_check_header_compile "$LINENO" "sys/umtx.h" "ac_cv_header_sys_umtx_h" "#include <errno.h>
#include <sys/types.h>

View File

@ -59,6 +59,13 @@ if test "x$FUTEX" = "xauto"; then
AC_CHECK_HEADER([linux/futex.h], [FUTEX=yes])
fi
if test "x$FUTEX" = "xauto"; then
AC_CHECK_HEADER([sys/futex.h], [FUTEX=yes])
if test "x$FUTEX" = "xyes"; then
AC_DEFINE(HAVE_FUTEX, 1, [Use futex])
fi
fi
if test "x$FUTEX" = "xauto"; then
AC_CHECK_HEADER([sys/umtx.h], [FUTEX=yes], [FUTEX=no],
[#include <errno.h>

View File

@ -26,7 +26,21 @@
#include <errno.h>
#ifdef HAVE_UMTX
#ifdef HAVE_FUTEX
#include <sys/time.h>
#include <sys/futex.h>
#include <limits.h>
static inline int futex_wake(int32_t *addr) {
return futex(addr, FUTEX_WAKE, INT_MAX, NULL, NULL);
}
static inline int futex_wait(int32_t *addr, int32_t value) {
return futex(addr, FUTEX_WAIT, value, NULL, NULL);
}
#elif HAVE_UMTX
#include <sys/types.h>
#include <sys/umtx.h>