Path: blob/main/crates/test-programs/src/async_.rs
1693 views
#[cfg(target_arch = "wasm32")]1#[link(wasm_import_module = "$root")]2unsafe extern "C" {3#[link_name = "[waitable-set-new]"]4pub fn waitable_set_new() -> u32;5}6#[cfg(not(target_arch = "wasm32"))]7pub unsafe fn waitable_set_new() -> u32 {8unreachable!()9}1011#[cfg(target_arch = "wasm32")]12#[link(wasm_import_module = "$root")]13unsafe extern "C" {14#[link_name = "[waitable-join]"]15pub fn waitable_join(waitable: u32, set: u32);16}17#[cfg(not(target_arch = "wasm32"))]18pub unsafe fn waitable_join(_: u32, _: u32) {19unreachable!()20}2122#[cfg(target_arch = "wasm32")]23#[link(wasm_import_module = "$root")]24unsafe extern "C" {25#[link_name = "[waitable-set-drop]"]26pub fn waitable_set_drop(set: u32);27}28#[cfg(not(target_arch = "wasm32"))]29pub unsafe fn waitable_set_drop(_: u32) {30unreachable!()31}3233#[cfg(not(target_arch = "wasm32"))]34pub unsafe fn waitable_set_poll_raw(_: u32, _: *mut u32) -> u32 {35unreachable!()36}37#[cfg(target_arch = "wasm32")]38#[link(wasm_import_module = "$root")]39unsafe extern "C" {40#[link_name = "[waitable-set-poll]"]41pub fn waitable_set_poll_raw(_: u32, _: *mut u32) -> u32;42}4344pub fn waitable_set_poll(set: u32) -> (u32, u32, u32) {45let mut payload = [0u32; 2];46let ret0 = unsafe { waitable_set_poll_raw(set, payload.as_mut_ptr()) };47(ret0, payload[0], payload[1])48}4950#[cfg(target_arch = "wasm32")]51#[link(wasm_import_module = "$root")]52unsafe extern "C" {53#[link_name = "[waitable-set-wait]"]54pub fn waitable_set_wait(set: u32, results: *mut u32) -> u32;55}56#[cfg(not(target_arch = "wasm32"))]57pub unsafe extern "C" fn waitable_set_wait(_set: u32, _results: *mut u32) -> u32 {58unreachable!()59}6061#[cfg(target_arch = "wasm32")]62#[link(wasm_import_module = "$root")]63unsafe extern "C" {64#[link_name = "[subtask-drop]"]65pub fn subtask_drop(task: u32);66}67#[cfg(not(target_arch = "wasm32"))]68pub unsafe fn subtask_drop(_: u32) {69unreachable!()70}7172#[cfg(target_arch = "wasm32")]73#[link(wasm_import_module = "$root")]74unsafe extern "C" {75#[link_name = "[subtask-cancel]"]76pub fn subtask_cancel(task: u32) -> u32;77}78#[cfg(not(target_arch = "wasm32"))]79pub unsafe fn subtask_cancel(_: u32) -> u32 {80unreachable!()81}8283#[cfg(target_arch = "wasm32")]84#[link(wasm_import_module = "$root")]85unsafe extern "C" {86#[link_name = "[async-lower][subtask-cancel]"]87pub fn subtask_cancel_async(task: u32) -> u32;88}89#[cfg(not(target_arch = "wasm32"))]90pub unsafe fn subtask_cancel_async(_: u32) -> u32 {91unreachable!()92}9394#[cfg(target_arch = "wasm32")]95#[link(wasm_import_module = "$root")]96unsafe extern "C" {97#[link_name = "[context-get-0]"]98pub fn context_get() -> u32;99}100#[cfg(not(target_arch = "wasm32"))]101pub unsafe fn context_get() -> u32 {102unreachable!()103}104105#[cfg(target_arch = "wasm32")]106#[link(wasm_import_module = "$root")]107unsafe extern "C" {108#[link_name = "[context-set-0]"]109pub fn context_set(value: u32);110}111#[cfg(not(target_arch = "wasm32"))]112pub unsafe fn context_set(_: u32) {113unreachable!()114}115116#[cfg(target_arch = "wasm32")]117#[link(wasm_import_module = "[export]$root")]118unsafe extern "C" {119#[link_name = "[task-cancel]"]120pub fn task_cancel();121}122#[cfg(not(target_arch = "wasm32"))]123pub unsafe extern "C" fn task_cancel() {124unreachable!()125}126127pub const STATUS_STARTING: u32 = 0;128pub const STATUS_STARTED: u32 = 1;129pub const STATUS_RETURNED: u32 = 2;130pub const STATUS_START_CANCELLED: u32 = 3;131pub const STATUS_RETURN_CANCELLED: u32 = 4;132133pub const EVENT_NONE: u32 = 0;134pub const EVENT_SUBTASK: u32 = 1;135pub const EVENT_STREAM_READ: u32 = 2;136pub const EVENT_STREAM_WRITE: u32 = 3;137pub const EVENT_FUTURE_READ: u32 = 4;138pub const EVENT_FUTURE_WRITE: u32 = 5;139pub const EVENT_CANCELLED: u32 = 6;140141pub const CALLBACK_CODE_EXIT: u32 = 0;142pub const CALLBACK_CODE_YIELD: u32 = 1;143pub const CALLBACK_CODE_WAIT: u32 = 2;144pub const CALLBACK_CODE_POLL: u32 = 3;145146pub const BLOCKED: u32 = 0xffff_ffff;147pub const DROPPED: u32 = 1;148pub const COMPLETED: u32 = 0;149150151