Skip to content

Commit a712598

Browse files
authored
Move emscripten_wasm_notify/wait functions from wasm_worker.h to atomic.h. NFC (#20381)
Also, rename them from `emscripten_wasm_xx` to `emscripten_atomic_xx` to match the other functions in this file (and the `emscripten_atomic_wait_async` functions which I've leaving in `wasm_workers.h` for now, but will likely move in a followup). In addition to moving these functions I've also added tests for using them in pthreads (based on the existing wasm worker tests). We should also probably move `emscripten_atomics_is_lock_free` but that can also be a followup.
1 parent 46a922e commit a712598

File tree

14 files changed

+228
-138
lines changed

14 files changed

+228
-138
lines changed

site/source/docs/api_reference/wasm_workers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ table.
287287

288288
<tr><td class='cellborder'>Futex API</td>
289289
<td class='cellborder'><pre>emscripten_futex_wait</pre><pre>emscripten_futex_wake</pre> in emscripten/threading.h</td>
290-
<td class='cellborder'><pre>emscripten_wasm_wait_i32</pre><pre>emscripten_wasm_wait_i64</pre><pre>emscripten_wasm_notify</pre> in emscripten/wasm_workers.h</td></tr>
290+
<td class='cellborder'><pre>emscripten_atomic_wait_u32</pre><pre>emscripten_atomic_wait_u64</pre><pre>emscripten_atomic_notify</pre> in emscripten/atomic.h</td></tr>
291291

292292
<tr><td class='cellborder'>Asynchronous futex wait</td>
293293
<td class='cellborder'>N/A</td>

system/include/emscripten/atomic.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,50 @@ _EM_INLINE void emscripten_atomic_fence(void) {
179179
emscripten_atomic_or_u8(&temp, 0);
180180
}
181181

182+
#define ATOMICS_WAIT_RESULT_T int
183+
184+
// Numbering dictated by https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait
185+
#define ATOMICS_WAIT_OK 0
186+
#define ATOMICS_WAIT_NOT_EQUAL 1
187+
#define ATOMICS_WAIT_TIMED_OUT 2
188+
189+
#define ATOMICS_WAIT_DURATION_INFINITE -1ll
190+
191+
// Issues the wasm 'memory.atomic.wait32' instruction:
192+
// If the given memory address contains value 'expectedValue', puts the calling
193+
// thread to sleep to wait for that address to be notified.
194+
// Returns one of the ATOMICS_WAIT_* return codes.
195+
// NOTE: This function takes in the wait value in int64_t nanosecond units. Pass
196+
// in maxWaitNanoseconds = -1 (or ATOMICS_WAIT_DURATION_INFINITE) to wait
197+
// infinitely long.
198+
_EM_INLINE ATOMICS_WAIT_RESULT_T emscripten_atomic_wait_u32(void /*uint32_t*/*addr __attribute__((nonnull)), uint32_t expectedValue, int64_t maxWaitNanoseconds) {
199+
return __builtin_wasm_memory_atomic_wait32((int32_t*)addr, expectedValue, maxWaitNanoseconds);
200+
}
201+
202+
// Issues the wasm 'memory.atomic.wait64' instruction:
203+
// If the given memory address contains value 'expectedValue', puts the calling
204+
// thread to sleep to wait for that address to be notified.
205+
// Returns one of the ATOMICS_WAIT_* return codes.
206+
// NOTE: This function takes in the wait value in int64_t nanosecond units. Pass
207+
// in maxWaitNanoseconds = -1 (or ATOMICS_WAIT_DURATION_INFINITE) to wait
208+
// infinitely long.
209+
_EM_INLINE ATOMICS_WAIT_RESULT_T emscripten_atomic_wait_u64(void /*uint64_t*/*addr __attribute__((nonnull)), uint64_t expectedValue, int64_t maxWaitNanoseconds) {
210+
return __builtin_wasm_memory_atomic_wait64((int64_t*)addr, expectedValue, maxWaitNanoseconds);
211+
}
212+
213+
#define EMSCRIPTEN_NOTIFY_ALL_WAITERS (-1LL)
214+
215+
// Issues the wasm 'memory.atomic.notify' instruction:
216+
// Notifies the given number of threads waiting on a location.
217+
// Pass count == EMSCRIPTEN_NOTIFY_ALL_WAITERS to notify all waiters on the
218+
// given location.
219+
// Returns the number of threads that were woken up.
220+
// Note: this function is used to notify both waiters waiting on an u32 and u64
221+
// addresses.
222+
_EM_INLINE int64_t emscripten_atomic_notify(void *addr __attribute__((nonnull)), int64_t count) {
223+
return __builtin_wasm_memory_atomic_notify((int*)addr, count);
224+
}
225+
182226
#undef _EM_INLINE
183227

184228
#ifdef __cplusplus

system/include/emscripten/wasm_worker.h

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <stdint.h>
44
#include <emscripten/html5.h>
5+
#include <emscripten/atomic.h>
56

67
#ifdef __cplusplus
78
extern "C" {
@@ -88,53 +89,6 @@ void emscripten_wasm_worker_post_function_vdd(emscripten_wasm_worker_t id, void
8889
void emscripten_wasm_worker_post_function_vddd(emscripten_wasm_worker_t id, void (*funcPtr)(double, double, double) __attribute__((nonnull)), double arg0, double arg1, double arg2);
8990
void emscripten_wasm_worker_post_function_sig(emscripten_wasm_worker_t id, void *funcPtr __attribute__((nonnull)), const char *sig __attribute__((nonnull)), ...);
9091

91-
#define ATOMICS_WAIT_RESULT_T int
92-
93-
// Numbering dictated by https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait
94-
#define ATOMICS_WAIT_OK 0
95-
#define ATOMICS_WAIT_NOT_EQUAL 1
96-
#define ATOMICS_WAIT_TIMED_OUT 2
97-
98-
#define ATOMICS_WAIT_DURATION_INFINITE -1ll
99-
100-
// Issues the wasm 'memory.atomic.wait32' instruction:
101-
// If the given memory address contains value 'expectedValue', puts the calling
102-
// thread to sleep to wait for that address to be notified.
103-
// Returns one of the ATOMICS_WAIT_* return codes.
104-
// NOTE: This function takes in the wait value in int64_t nanosecond units. Pass
105-
// in maxWaitNanoseconds = -1 (or ATOMICS_WAIT_DURATION_INFINITE) to wait
106-
// infinitely long.
107-
static __attribute__((always_inline)) ATOMICS_WAIT_RESULT_T emscripten_wasm_wait_i32(int32_t *address __attribute__((nonnull)), int expectedValue, int64_t maxWaitNanoseconds)
108-
{
109-
return __builtin_wasm_memory_atomic_wait32(address, expectedValue, maxWaitNanoseconds);
110-
}
111-
112-
// Issues the wasm 'memory.atomic.wait64' instruction:
113-
// If the given memory address contains value 'expectedValue', puts the calling
114-
// thread to sleep to wait for that address to be notified.
115-
// Returns one of the ATOMICS_WAIT_* return codes.
116-
// NOTE: This function takes in the wait value in int64_t nanosecond units. Pass
117-
// in maxWaitNanoseconds = -1 (or ATOMICS_WAIT_DURATION_INFINITE) to wait
118-
// infinitely long.
119-
static __attribute__((always_inline)) ATOMICS_WAIT_RESULT_T emscripten_wasm_wait_i64(int64_t *address __attribute__((nonnull)), int64_t expectedValue, int64_t maxWaitNanoseconds)
120-
{
121-
return __builtin_wasm_memory_atomic_wait64(address, expectedValue, maxWaitNanoseconds);
122-
}
123-
124-
#define EMSCRIPTEN_NOTIFY_ALL_WAITERS (-1LL)
125-
126-
// Issues the wasm 'memory.atomic.notify' instruction:
127-
// Notifies the given number of threads waiting on a location.
128-
// Pass count == EMSCRIPTEN_NOTIFY_ALL_WAITERS to notify all waiters on the
129-
// given location.
130-
// Returns the number of threads that were woken up.
131-
// Note: this function is used to notify both waiters waiting on an i32 and i64
132-
// addresses.
133-
static __attribute__((always_inline)) int64_t emscripten_wasm_notify(int32_t *address __attribute__((nonnull)), int64_t count)
134-
{
135-
return __builtin_wasm_memory_atomic_notify(address, count);
136-
}
137-
13892
#define EMSCRIPTEN_WAIT_ASYNC_INFINITY __builtin_inf()
13993

14094
// Represents a pending 'Atomics.waitAsync' wait operation.
@@ -147,8 +101,8 @@ static __attribute__((always_inline)) int64_t emscripten_wasm_notify(int32_t *ad
147101
// 'address' contains 'value', issues a deferred wait that will invoke the
148102
// specified callback function 'asyncWaitFinished' once that address has been
149103
// notified by another thread.
150-
// NOTE: Unlike functions emscripten_wasm_wait_i32() and
151-
// emscripten_wasm_wait_i64() which take in the wait timeout parameter as int64
104+
// NOTE: Unlike functions emscripten_atomic_wait_u32() and
105+
// emscripten_atomic_wait_u64() which take in the wait timeout parameter as int64
152106
// nanosecond units, this function takes in the wait timeout parameter as double
153107
// millisecond units. See https://github.com/WebAssembly/threads/issues/175 for
154108
// more information.
@@ -389,6 +343,15 @@ ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t *condvar
389343
// ("broadcast" operation).
390344
void emscripten_condvar_signal(emscripten_condvar_t *condvar __attribute__((nonnull)), int64_t numWaitersToSignal);
391345

346+
// Legacy names for emscripten_atomic_wait/notify functions, defined in
347+
// emscripten/atomic.h
348+
#define emscripten_wasm_wait_i32 emscripten_atomic_wait_u32
349+
#define emscripten_wasm_wait_i64 emscripten_atomic_wait_u64
350+
#define emscripten_wasm_notify emscripten_atomic_notify
351+
#pragma clang deprecated(emscripten_wasm_wait_i32, "use emscripten_atomic_wait_u32 instead")
352+
#pragma clang deprecated(emscripten_wasm_wait_i64, "use emscripten_atomic_wait_u64 instead")
353+
#pragma clang deprecated(emscripten_wasm_notify, "use emscripten_atomic_notify instead")
354+
392355
#ifdef __cplusplus
393356
}
394357
#endif

system/lib/wasm_worker/library_wasm_worker.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ emscripten_wasm_worker_t emscripten_malloc_wasm_worker(size_t stackSize)
7777
void emscripten_wasm_worker_sleep(int64_t nsecs)
7878
{
7979
int32_t addr = 0;
80-
emscripten_wasm_wait_i32(&addr, 0, nsecs);
80+
emscripten_atomic_wait_u32(&addr, 0, nsecs);
8181
}
8282

8383
void emscripten_lock_init(emscripten_lock_t *lock)
@@ -92,7 +92,7 @@ EM_BOOL emscripten_lock_wait_acquire(emscripten_lock_t *lock, int64_t maxWaitNan
9292
int64_t waitEnd = (int64_t)(emscripten_performance_now() * 1e6) + maxWaitNanoseconds;
9393
while(maxWaitNanoseconds > 0)
9494
{
95-
emscripten_wasm_wait_i32((int32_t*)lock, val, maxWaitNanoseconds);
95+
emscripten_atomic_wait_u32((int32_t*)lock, val, maxWaitNanoseconds);
9696
val = emscripten_atomic_cas_u32((void*)lock, 0, 1);
9797
if (!val) return EM_TRUE;
9898
maxWaitNanoseconds = waitEnd - (int64_t)(emscripten_performance_now() * 1e6);
@@ -107,7 +107,7 @@ void emscripten_lock_waitinf_acquire(emscripten_lock_t *lock)
107107
{
108108
val = emscripten_atomic_cas_u32((void*)lock, 0, 1);
109109
if (val)
110-
emscripten_wasm_wait_i32((int32_t*)lock, val, ATOMICS_WAIT_DURATION_INFINITE);
110+
emscripten_atomic_wait_u32((int32_t*)lock, val, ATOMICS_WAIT_DURATION_INFINITE);
111111
} while(val);
112112
}
113113

@@ -145,7 +145,7 @@ EM_BOOL emscripten_lock_try_acquire(emscripten_lock_t *lock)
145145
void emscripten_lock_release(emscripten_lock_t *lock)
146146
{
147147
emscripten_atomic_store_u32((void*)lock, 0);
148-
emscripten_wasm_notify((int32_t*)lock, 1);
148+
emscripten_atomic_notify((int32_t*)lock, 1);
149149
}
150150

151151
void emscripten_semaphore_init(emscripten_semaphore_t *sem, int num)
@@ -173,7 +173,7 @@ int emscripten_semaphore_wait_acquire(emscripten_semaphore_t *sem, int num, int6
173173
while(val < num)
174174
{
175175
// TODO: Shave off maxWaitNanoseconds
176-
ATOMICS_WAIT_RESULT_T waitResult = emscripten_wasm_wait_i32((int32_t*)sem, val, maxWaitNanoseconds);
176+
ATOMICS_WAIT_RESULT_T waitResult = emscripten_atomic_wait_u32((int32_t*)sem, val, maxWaitNanoseconds);
177177
if (waitResult == ATOMICS_WAIT_TIMED_OUT) return -1;
178178
val = emscripten_atomic_load_u32((void*)sem);
179179
}
@@ -190,7 +190,7 @@ int emscripten_semaphore_waitinf_acquire(emscripten_semaphore_t *sem, int num)
190190
{
191191
while(val < num)
192192
{
193-
emscripten_wasm_wait_i32((int32_t*)sem, val, ATOMICS_WAIT_DURATION_INFINITE);
193+
emscripten_atomic_wait_u32((int32_t*)sem, val, ATOMICS_WAIT_DURATION_INFINITE);
194194
val = emscripten_atomic_load_u32((void*)sem);
195195
}
196196
int ret = (int)emscripten_atomic_cas_u32((void*)sem, val, val - num);
@@ -202,7 +202,7 @@ int emscripten_semaphore_waitinf_acquire(emscripten_semaphore_t *sem, int num)
202202
uint32_t emscripten_semaphore_release(emscripten_semaphore_t *sem, int num)
203203
{
204204
uint32_t ret = emscripten_atomic_add_u32((void*)sem, num);
205-
emscripten_wasm_notify((int*)sem, num);
205+
emscripten_atomic_notify((int*)sem, num);
206206
return ret;
207207
}
208208

@@ -215,15 +215,15 @@ void emscripten_condvar_waitinf(emscripten_condvar_t *condvar, emscripten_lock_t
215215
{
216216
int val = emscripten_atomic_load_u32((void*)condvar);
217217
emscripten_lock_release(lock);
218-
emscripten_wasm_wait_i32((int32_t*)condvar, val, ATOMICS_WAIT_DURATION_INFINITE);
218+
emscripten_atomic_wait_u32((int32_t*)condvar, val, ATOMICS_WAIT_DURATION_INFINITE);
219219
emscripten_lock_waitinf_acquire(lock);
220220
}
221221

222222
EM_BOOL emscripten_condvar_wait(emscripten_condvar_t *condvar, emscripten_lock_t *lock, int64_t maxWaitNanoseconds)
223223
{
224224
int val = emscripten_atomic_load_u32((void*)condvar);
225225
emscripten_lock_release(lock);
226-
int waitValue = emscripten_wasm_wait_i32((int32_t*)condvar, val, maxWaitNanoseconds);
226+
int waitValue = emscripten_atomic_wait_u32((int32_t*)condvar, val, maxWaitNanoseconds);
227227
if (waitValue == ATOMICS_WAIT_TIMED_OUT)
228228
return EM_FALSE;
229229

@@ -244,5 +244,5 @@ ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t *condvar
244244
void emscripten_condvar_signal(emscripten_condvar_t *condvar, int64_t numWaitersToSignal)
245245
{
246246
emscripten_atomic_add_u32((void*)condvar, 1);
247-
emscripten_wasm_notify((int*)condvar, numWaitersToSignal);
247+
emscripten_atomic_notify((int*)condvar, numWaitersToSignal);
248248
}

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5353,12 +5353,12 @@ def test_wasm_worker_post_function_to_main_thread(self):
53535353
def test_wasm_worker_hardware_concurrency_is_lock_free(self):
53545354
self.btest('wasm_worker/hardware_concurrency_is_lock_free.c', expected='0', args=['-sWASM_WORKERS'])
53555355

5356-
# Tests emscripten_wasm_wait_i32() and emscripten_wasm_notify() functions.
5356+
# Tests emscripten_atomic_wait_u32() and emscripten_atomic_notify() functions.
53575357
@also_with_minimal_runtime
53585358
def test_wasm_worker_wait32_notify(self):
53595359
self.btest('wasm_worker/wait32_notify.c', expected='2', args=['-sWASM_WORKERS'])
53605360

5361-
# Tests emscripten_wasm_wait_i64() and emscripten_wasm_notify() functions.
5361+
# Tests emscripten_atomic_wait_u64() and emscripten_atomic_notify() functions.
53625362
@also_with_minimal_runtime
53635363
def test_wasm_worker_wait64_notify(self):
53645364
self.btest('wasm_worker/wait64_notify.c', expected='2', args=['-sWASM_WORKERS'])

test/test_core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,6 +2921,15 @@ def test_pthread_run_script(self):
29212921
self.set_setting('EXIT_RUNTIME')
29222922
self.do_runf(test_file('pthread/test_pthread_run_script.c'))
29232923

2924+
@node_pthreads
2925+
def test_pthread_wait32_notify(self):
2926+
self.do_run_in_out_file_test(test_file('wasm_worker/wait32_notify.c'))
2927+
2928+
@node_pthreads
2929+
@no_wasm2js('https://github.com/WebAssembly/binaryen/issues/5991')
2930+
def test_pthread_wait64_notify(self):
2931+
self.do_run_in_out_file_test(test_file('wasm_worker/wait64_notify.c'))
2932+
29242933
def test_tcgetattr(self):
29252934
self.do_runf(test_file('termios/test_tcgetattr.c'), 'success')
29262935

test/wasm_worker/cancel_all_wait_asyncs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ int main()
4747
assert(r == EMSCRIPTEN_RESULT_INVALID_PARAM);
4848

4949
emscripten_console_log("Notifying an async wait should not trigger the callback function");
50-
int64_t numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
50+
int64_t numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
5151

5252
emscripten_console_log("Notifying an async wait should return 0 threads woken");
5353
assert(numWoken == 0);
5454

5555
addr = 2;
5656
emscripten_console_log("Notifying an async wait even after changed value should not trigger the callback function");
57-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
57+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
5858

5959
emscripten_console_log("Notifying an async wait should return 0 threads woken");
6060
assert(numWoken == 0);
@@ -65,12 +65,12 @@ int main()
6565

6666
#if 0
6767
emscripten_console_log("Notifying an async wait without value changing should still trigger the callback");
68-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
68+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
6969
assert(numWoken == 1);
7070
#else
7171
// TODO: Switch to the above test instead after the Atomics.waitAsync() polyfill is dropped.
7272
addr = 3;
7373
emscripten_console_log("Notifying an async wait after value changing should trigger the callback");
74-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
74+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
7575
#endif
7676
}

test/wasm_worker/cancel_all_wait_asyncs_at_address.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ int main()
5151
assert(r == EMSCRIPTEN_RESULT_INVALID_PARAM);
5252

5353
emscripten_console_log("Notifying an async wait should not trigger the callback function");
54-
int64_t numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
54+
int64_t numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
5555

5656
emscripten_console_log("Notifying an async wait should return 0 threads woken");
5757
assert(numWoken == 0);
5858

5959
addr = 2;
6060
emscripten_console_log("Notifying an async wait even after changed value should not trigger the callback function");
61-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
61+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
6262

6363
emscripten_console_log("Notifying an async wait should return 0 threads woken");
6464
assert(numWoken == 0);
@@ -69,12 +69,12 @@ int main()
6969

7070
#if 0
7171
emscripten_console_log("Notifying an async wait without value changing should still trigger the callback");
72-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
72+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
7373
assert(numWoken == 1);
7474
#else
7575
// TODO: Switch to the above test instead after the Atomics.waitAsync() polyfill is dropped.
7676
addr = 3;
7777
emscripten_console_log("Notifying an async wait after value changing should trigger the callback");
78-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
78+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
7979
#endif
8080
}

test/wasm_worker/cancel_wait_async.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ int main()
3939
assert(r == EMSCRIPTEN_RESULT_INVALID_PARAM);
4040

4141
emscripten_console_log("Notifying an async wait should not trigger the callback function");
42-
int64_t numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
42+
int64_t numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
4343

4444
emscripten_console_log("Notifying an async wait should return 0 threads woken");
4545
assert(numWoken == 0);
4646

4747
addr = 2;
4848
emscripten_console_log("Notifying an async wait even after changed value should not trigger the callback function");
49-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
49+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
5050

5151
emscripten_console_log("Notifying an async wait should return 0 threads woken");
5252
assert(numWoken == 0);
@@ -57,12 +57,12 @@ int main()
5757

5858
#if 0
5959
emscripten_console_log("Notifying an async wait without value changing should still trigger the callback");
60-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
60+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
6161
assert(numWoken == 1);
6262
#else
6363
// TODO: Switch to the above test instead after the Atomics.waitAsync() polyfill is dropped.
6464
addr = 3;
6565
emscripten_console_log("Notifying an async wait after value changing should trigger the callback");
66-
numWoken = emscripten_wasm_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
66+
numWoken = emscripten_atomic_notify((int32_t*)&addr, EMSCRIPTEN_NOTIFY_ALL_WAITERS);
6767
#endif
6868
}

0 commit comments

Comments
 (0)