Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/lib/pthread/emscripten_futex_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int emscripten_futex_wait(volatile void *addr, uint32_t val, double max_wait_ms)
}
// If remainder_ns is negative it means we want wait forever, and we don't
// need to decrement remainder_ns in that case.
if (wakeup_interval && remainder_ns > 0) {
if (wakeup_interval && remainder_ns >= 0) {
remainder_ns -= wakeup_interval;
if (remainder_ns <= 0) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ int main() {
rc = emscripten_futex_wait(&futex_value, futex_value, 1);
assert(rc == -ETIMEDOUT);

// As should this.
rc = emscripten_futex_wait(&futex_value, futex_value, 0);
assert(rc == -ETIMEDOUT);

// Check that this thread has removed itself from the wait queue.
rc = emscripten_futex_wake(&futex_value, INT_MAX);
assert(rc == 0);
Expand Down
4 changes: 2 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9251,10 +9251,10 @@ def test_emscripten_atomics(self):
self.do_core_test('pthread/emscripten_atomics.c', cflags=['-pthread'])

@requires_pthreads
def test_emscripten_futexes(self):
def test_emscripten_futex_api_basics(self):
# This test explicitly checks behavior of passing NULL to emscripten_futex_wake() so
# need to disable the `-Wno-nonnull` to disabled these warnings.
self.do_core_test('pthread/emscripten_futexes.c', cflags=['-pthread', '-Wno-nonnull'])
self.do_core_test('pthread/emscripten_futex_api_basics.c', cflags=['-pthread', '-Wno-nonnull'])

@requires_pthreads
def test_stdio_locking(self):
Expand Down
Loading