Skip to content

Commit a3750a3

Browse files
authored
Update emscripten_atomic_notify to take uint32_t for count. NFC (#26459)
This matches the specification of the underlying atomic.wait instruction. This should be a non-breaking change in almost all cases.
1 parent ff125f7 commit a3750a3

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

system/include/emscripten/atomic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ _EM_INLINE ATOMICS_WAIT_RESULT_T emscripten_atomic_wait_u64(void /*uint64_t*/* _
220220
return __builtin_wasm_memory_atomic_wait64((int64_t*)addr, expectedValue, maxWaitNanoseconds);
221221
}
222222

223-
#define EMSCRIPTEN_NOTIFY_ALL_WAITERS (-1LL)
223+
#define EMSCRIPTEN_NOTIFY_ALL_WAITERS UINT32_MAX
224224

225225
// Issues the wasm 'memory.atomic.notify' instruction:
226226
// Notifies the given number of threads waiting on a location.
@@ -229,7 +229,7 @@ _EM_INLINE ATOMICS_WAIT_RESULT_T emscripten_atomic_wait_u64(void /*uint64_t*/* _
229229
// Returns the number of threads that were woken up.
230230
// Note: this function is used to notify both waiters waiting on an u32 and u64
231231
// addresses.
232-
_EM_INLINE int64_t emscripten_atomic_notify(void * _Nonnull addr, int64_t count) {
232+
_EM_INLINE int64_t emscripten_atomic_notify(void * _Nonnull addr, uint32_t count) {
233233
return __builtin_wasm_memory_atomic_notify((int*)addr, count);
234234
}
235235

system/include/emscripten/threading_primitives.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t * _Nonnu
184184
// Signals the given number of waiters on the specified condition variable.
185185
// Pass numWaitersToSignal == EMSCRIPTEN_NOTIFY_ALL_WAITERS to wake all waiters
186186
// ("broadcast" operation).
187-
void emscripten_condvar_signal(emscripten_condvar_t * _Nonnull condvar, int64_t numWaitersToSignal);
187+
void emscripten_condvar_signal(emscripten_condvar_t * _Nonnull condvar, uint32_t numWaitersToSignal);
188188

189189
// If the given memory address contains value val, puts the calling thread to
190190
// sleep waiting for that address to be notified.

system/lib/pthread/emscripten_thread_primitives.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t *condvar
153153
return emscripten_atomic_wait_async((void*)condvar, val, asyncWaitFinished, userData, maxWaitMilliseconds);
154154
}
155155

156-
void emscripten_condvar_signal(emscripten_condvar_t *condvar, int64_t numWaitersToSignal) {
156+
void emscripten_condvar_signal(emscripten_condvar_t *condvar, uint32_t numWaitersToSignal) {
157157
emscripten_atomic_add_u32((void*)condvar, 1);
158158
emscripten_atomic_notify((void*)condvar, numWaitersToSignal);
159159
}

0 commit comments

Comments
 (0)