From f0022d6e3231bccf80815371839f7c9d76b71add Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 23 Oct 2023 20:40:24 +0000 Subject: [PATCH] create __OpenBSD__ versions that use futex() with the correct number of arguments and without using syscall(). the glibc people should be ashamed of the mess they created. ok miod --- gnu/llvm/libcxxabi/src/cxa_guard_impl.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gnu/llvm/libcxxabi/src/cxa_guard_impl.h b/gnu/llvm/libcxxabi/src/cxa_guard_impl.h index 6f873f241fa..5ca4c571563 100644 --- a/gnu/llvm/libcxxabi/src/cxa_guard_impl.h +++ b/gnu/llvm/libcxxabi/src/cxa_guard_impl.h @@ -395,7 +395,20 @@ private: // Futex Implementation //===----------------------------------------------------------------------===// -#if defined(SYS_futex) +#ifdef __OpenBSD__ +#include + +void PlatformFutexWait(int* addr, int expect) { + constexpr int WAIT = 0; + futex((volatile uint32_t *)addr, WAIT, expect, NULL, NULL); + __tsan_acquire(addr); +} +void PlatformFutexWake(int* addr) { + constexpr int WAKE = 1; + __tsan_release(addr); + futex((volatile uint32_t *)addr, WAKE, INT_MAX, NULL, NULL); +} +#elif defined(SYS_futex) void PlatformFutexWait(int* addr, int expect) { constexpr int WAIT = 0; syscall(SYS_futex, addr, WAIT, expect, 0); -- 2.20.1