Skip to content

Commit 232b9dc

Browse files
deraadtmordak
authored andcommitted
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
1 parent 5f07464 commit 232b9dc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

libcxxabi/src/cxa_guard_impl.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,20 @@ struct InitByteGlobalMutex {
411411
// Futex Implementation
412412
//===----------------------------------------------------------------------===//
413413

414-
#if defined(SYS_futex)
414+
#ifdef __OpenBSD__
415+
#include <sys/futex.h>
416+
417+
void PlatformFutexWait(int* addr, int expect) {
418+
constexpr int WAIT = 0;
419+
futex((volatile uint32_t *)addr, WAIT, expect, NULL, NULL);
420+
__tsan_acquire(addr);
421+
}
422+
void PlatformFutexWake(int* addr) {
423+
constexpr int WAKE = 1;
424+
__tsan_release(addr);
425+
futex((volatile uint32_t *)addr, WAKE, INT_MAX, NULL, NULL);
426+
}
427+
#elif defined(SYS_futex)
415428
void PlatformFutexWait(int* addr, int expect) {
416429
constexpr int WAIT = 0;
417430
syscall(SYS_futex, addr, WAIT, expect, 0);

0 commit comments

Comments
 (0)