| 14 | volatile int64_t addr = 0; |
| 15 | |
| 16 | void run_test() { |
| 17 | emscripten_out("worker_main"); |
| 18 | emscripten_atomic_store_u64((void*)&addr, 0x100000000ull); |
| 19 | |
| 20 | emscripten_out("Waiting on address with unexpected value should return 'not-equal'"); |
| 21 | ATOMICS_WAIT_RESULT_T ret = emscripten_atomic_wait_u64((int64_t*)&addr, 0x200000000ull, /*timeout=*/-1); |
| 22 | assert(ret == ATOMICS_WAIT_NOT_EQUAL); |
| 23 | |
| 24 | emscripten_out("Waiting on address with unexpected value should return 'not-equal' also if timeout==0"); |
| 25 | ret = emscripten_atomic_wait_u64((int64_t*)&addr, 0x200000000ull, /*timeout=*/0); |
| 26 | assert(ret == ATOMICS_WAIT_NOT_EQUAL); |
| 27 | |
| 28 | emscripten_out("Waiting for 0 nanoseconds should return 'timed-out'"); |
| 29 | ret = emscripten_atomic_wait_u64((int64_t*)&addr, 0x100000000ull, /*timeout=*/0); |
| 30 | assert(ret == ATOMICS_WAIT_TIMED_OUT); |
| 31 | |
| 32 | emscripten_out("Waiting for >0 nanoseconds should return 'timed-out'"); |
| 33 | ret = emscripten_atomic_wait_u64((int64_t*)&addr, 0x100000000ull, /*timeout=*/1000); |
| 34 | assert(ret == ATOMICS_WAIT_TIMED_OUT); |
| 35 | |
| 36 | emscripten_out("Waiting for infinitely long should return 'ok'"); |
| 37 | emscripten_atomic_store_u64((void*)&addr, 0x300000000ull); |
| 38 | ret = emscripten_atomic_wait_u64((int64_t*)&addr, 0x300000000ull, /*timeout=*/-1); |
| 39 | assert(ret == ATOMICS_WAIT_OK); |
| 40 | |
| 41 | emscripten_out("Test finished"); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | // This test run in both wasm workers and pthreads mode |
no test coverage detected