13
0

Explicitly initialize futex word

This is mainly to silence valgrind warnings, the actual value
is irrelevant here.
This commit is contained in:
Robin Gareus 2022-11-13 02:45:48 +01:00
parent 949f9e6051
commit 2ae670055d
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -52,6 +52,7 @@ Semaphore::Semaphore (const char* name, int val)
#elif defined USE_FUTEX_SEMAPHORE
(void)name; /* stop warning */
_value = val;
_futex = 0;
#else
(void) name; /* stop gcc warning on !Apple systems */
@ -116,7 +117,7 @@ int
Semaphore::wait ()
{
if (std::atomic_fetch_sub_explicit (&_value, 1, std::memory_order_relaxed) <= 0) {
syscall(SYS_futex, &_futex, FUTEX_WAIT_PRIVATE, _futex, NULL, 0, 0);
syscall(SYS_futex, &_futex, FUTEX_WAIT_PRIVATE, _futex, NULL, NULL, 0);
}
return 0;
}