@@ -39,18 +39,27 @@ extern "C" {
3939 fn emscripten_clear_immediate ( id : i32 ) ;
4040}
4141
42+ /// `em_settled_result_t`, returned by value.
43+ #[ repr( C ) ]
44+ struct SettledResult {
45+ result : i32 ,
46+ value : * mut c_void ,
47+ }
48+
4249extern "C-unwind" {
4350 // Suspending import (Emscripten marks it `__async`): resolves to the
44- // promise's value once it settles . Under `-sJSPI` the wrapper is
51+ // promise's settled result . Under `-sJSPI` the wrapper is
4552 // `Asyncify.handleAsync`, which keeps the runtime alive across the
46- // suspension. Linkable without JSPI, where it aborts if reached.
53+ // suspension. Linkable without JSPI, where it aborts if reached. Present
54+ // in every Emscripten the Rust target supports, unlike the newer
55+ // `emscripten_promise_await_unchecked`.
4756 //
4857 // Suspension needs a `WebAssembly.promising` activation on the stack.
4958 // From any other activation (a plain host callback into the module) the
5059 // engine throws `WebAssembly.SuspendError` out of this import instead. It
5160 // is a foreign exception to Rust: drops run as it unwinds, `catch_unwind`
5261 // does not catch it, and it aborts at the first `extern "C"` frame.
53- fn emscripten_promise_await_unchecked ( promise : Promise ) -> * mut c_void ;
62+ fn emscripten_promise_await ( promise : Promise ) -> SettledResult ;
5463}
5564
5665/// Whether JSPI suspension is available: linked with `-sJSPI`.
@@ -160,8 +169,9 @@ pub(crate) fn park(slot: &Slot, dur: Option<Duration>) {
160169
161170 // SAFETY: the handle is live. Under `-sJSPI` this suspends the
162171 // activation; the caller has checked `jspi_enabled`. A `SuspendError`
163- // unwinding out of it drops `park`, clearing the timer and handle.
164- unsafe { emscripten_promise_await_unchecked ( park. promise ) } ;
172+ // unwinding out of it drops `park`, clearing the timer and handle. The
173+ // promise is only ever fulfilled, so the result carries nothing.
174+ let _ = unsafe { emscripten_promise_await ( park. promise ) } ;
165175}
166176
167177/// Resume the activation parked on `slot`, if any.
0 commit comments