Skip to content

Commit

Permalink
atomic_sync: Use the correct struct timespec on NetBSD for futex.
Browse files Browse the repository at this point in the history
This is a minimum fix for the NetBSD futex syscall, but perhaps it
would be better to just use struct timespec on all systems and have a
special case for Linux's pre-64-bit-time_t syscall.

fix #49
  • Loading branch information
Taylor R Campbell committed Jul 6, 2024
1 parent edd93ca commit a39e9f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bee/thread/atomic_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ static void futex_wait(const int* ptr, int val, const FutexTimespec* timeout) {
# if defined(__linux__)
::syscall(SYS_futex, ptr, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, timeout, 0, 0);
# elif defined(__NetBSD__)
::syscall(SYS___futex, ptr, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, timeout, 0, 0, 0);
struct timespec ts = {
.tv_sec = timeout.tv_sec,
.tv_nsec = timeout.tv,
};
::syscall(SYS___futex, ptr, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, &ts, 0, 0, 0);
# elif defined(__OpenBSD__)
static_assert(sizeof(FutexTimespec) == sizeof(timespec));
::futex((uint32_t*)const_cast<int*>(ptr), FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, (const timespec*)timeout, 0);
Expand Down

0 comments on commit a39e9f4

Please sign in to comment.