Path: blob/main/crates/test-programs/src/bin/async_yield_callee_stackless.rs
1693 views
#![expect(unsafe_op_in_unsafe_fn, reason = "old code, not worth updating yet")]12mod bindings {3wit_bindgen::generate!({4path: "../misc/component-async-tests/wit",5world: "yield-callee",6});7}89use {10bindings::local::local::continue_,11test_programs::async_::{CALLBACK_CODE_EXIT, CALLBACK_CODE_YIELD, EVENT_CANCELLED, EVENT_NONE},12};1314#[cfg(target_arch = "wasm32")]15#[link(wasm_import_module = "[export]local:local/run")]16unsafe extern "C" {17#[link_name = "[task-return][async]run"]18fn task_return_run();19}20#[cfg(not(target_arch = "wasm32"))]21unsafe extern "C" fn task_return_run() {22unreachable!()23}2425#[unsafe(export_name = "[async-lift]local:local/run#[async]run")]26unsafe extern "C" fn export_run() -> u32 {27callback_run(EVENT_NONE, 0, 0)28}2930#[unsafe(export_name = "[callback][async-lift]local:local/run#[async]run")]31unsafe extern "C" fn callback_run(event0: u32, _event1: u32, _event2: u32) -> u32 {32assert!(event0 == EVENT_NONE || event0 == EVENT_CANCELLED);3334if continue_::get_continue() && event0 == EVENT_NONE {35CALLBACK_CODE_YIELD36} else {37task_return_run();38CALLBACK_CODE_EXIT39}40}4142// Unused function; required since this file is built as a `bin`:43fn main() {}444546