Skip to content

Commit adbeb1b

Browse files
authored
Align subtask return codes with the spec (bytecodealliance#1272)
Coupled with upstream changes to wasip3-prototyping...
1 parent ef86474 commit adbeb1b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/guest-rust/rt/src/async_support/subtask.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ unsafe impl<T: Subtask> WaitableOp for SubtaskOps<T> {
8080
let (ptr_params, cleanup) = Cleanup::new(T::ABI_LAYOUT);
8181
let ptr_results = ptr_params.add(T::RESULTS_OFFSET);
8282
T::params_lower(state.params, ptr_params);
83-
let result = T::call_import(ptr_params, ptr_results);
84-
// FIXME(bytecodealliance/wasip3-prototyping#99) the decoding of the
85-
// result here isn't standards-compliant.
86-
let code = result >> 30;
87-
let subtask =
88-
NonZeroU32::new((result << 2) >> 2).map(|handle| SubtaskHandle { handle });
83+
let packed = T::call_import(ptr_params, ptr_results);
84+
let code = packed & 0xf;
85+
let subtask = NonZeroU32::new(packed >> 4).map(|handle| SubtaskHandle { handle });
86+
rtdebug!("<import>({ptr_params:?}, {ptr_results:?}) = ({code:#x}, {subtask:#x?})");
8987

9088
(
9189
code,

0 commit comments

Comments
 (0)