create __OpenBSD__ versions that use futex() with the correct number
authorderaadt <deraadt@openbsd.org>
Mon, 23 Oct 2023 20:40:24 +0000 (20:40 +0000)
committerderaadt <deraadt@openbsd.org>
Mon, 23 Oct 2023 20:40:24 +0000 (20:40 +0000)
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

index 6f873f2..5ca4c57 100644 (file)
@@ -395,7 +395,20 @@ private:
 //                         Futex Implementation
 //===----------------------------------------------------------------------===//
 
-#if defined(SYS_futex)
+#ifdef __OpenBSD__
+#include <sys/futex.h>
+
+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);