1 #[cfg(target_arch = "wasm32")] 2 #[link(wasm_import_module = "$root")] 3 unsafe extern "C" { 4 #[link_name = "[waitable-set-new]"] 5 pub fn waitable_set_new() -> u32; 6 } 7 #[cfg(not(target_arch = "wasm32"))] 8 pub unsafe fn waitable_set_new() -> u32 { 9 unreachable!() 10 } 11 12 #[cfg(target_arch = "wasm32")] 13 #[link(wasm_import_module = "$root")] 14 unsafe extern "C" { 15 #[link_name = "[waitable-join]"] 16 pub fn waitable_join(waitable: u32, set: u32); 17 } 18 #[cfg(not(target_arch = "wasm32"))] 19 pub unsafe fn waitable_join(_: u32, _: u32) { 20 unreachable!() 21 } 22 23 #[cfg(target_arch = "wasm32")] 24 #[link(wasm_import_module = "$root")] 25 unsafe extern "C" { 26 #[link_name = "[waitable-set-drop]"] 27 pub fn waitable_set_drop(set: u32); 28 } 29 #[cfg(not(target_arch = "wasm32"))] 30 pub unsafe fn waitable_set_drop(_: u32) { 31 unreachable!() 32 } 33 34 #[cfg(not(target_arch = "wasm32"))] 35 pub unsafe fn waitable_set_poll_raw(_: u32, _: *mut u32) -> u32 { 36 unreachable!() 37 } 38 #[cfg(target_arch = "wasm32")] 39 #[link(wasm_import_module = "$root")] 40 unsafe extern "C" { 41 #[link_name = "[waitable-set-poll]"] 42 pub fn waitable_set_poll_raw(_: u32, _: *mut u32) -> u32; 43 } 44 45 pub fn waitable_set_poll(set: u32) -> (u32, u32, u32) { 46 let mut payload = [0u32; 2]; 47 let ret0 = unsafe { waitable_set_poll_raw(set, payload.as_mut_ptr()) }; 48 (ret0, payload[0], payload[1]) 49 } 50 51 #[cfg(target_arch = "wasm32")] 52 #[link(wasm_import_module = "$root")] 53 unsafe extern "C" { 54 #[link_name = "[waitable-set-wait]"] 55 pub fn waitable_set_wait(set: u32, results: *mut u32) -> u32; 56 } 57 #[cfg(not(target_arch = "wasm32"))] 58 pub unsafe extern "C" fn waitable_set_wait(_set: u32, _results: *mut u32) -> u32 { 59 unreachable!() 60 } 61 62 #[cfg(target_arch = "wasm32")] 63 #[link(wasm_import_module = "$root")] 64 unsafe extern "C" { 65 #[link_name = "[subtask-drop]"] 66 pub fn subtask_drop(task: u32); 67 } 68 #[cfg(not(target_arch = "wasm32"))] 69 pub unsafe fn subtask_drop(_: u32) { 70 unreachable!() 71 } 72 73 #[cfg(target_arch = "wasm32")] 74 #[link(wasm_import_module = "$root")] 75 unsafe extern "C" { 76 #[link_name = "[subtask-cancel]"] 77 pub fn subtask_cancel(task: u32) -> u32; 78 } 79 #[cfg(not(target_arch = "wasm32"))] 80 pub unsafe fn subtask_cancel(_: u32) -> u32 { 81 unreachable!() 82 } 83 84 #[cfg(target_arch = "wasm32")] 85 #[link(wasm_import_module = "$root")] 86 unsafe extern "C" { 87 #[link_name = "[async-lower][subtask-cancel]"] 88 pub fn subtask_cancel_async(task: u32) -> u32; 89 } 90 #[cfg(not(target_arch = "wasm32"))] 91 pub unsafe fn subtask_cancel_async(_: u32) -> u32 { 92 unreachable!() 93 } 94 95 #[cfg(target_arch = "wasm32")] 96 #[link(wasm_import_module = "$root")] 97 unsafe extern "C" { 98 #[link_name = "[context-get-0]"] 99 pub fn context_get() -> u32; 100 } 101 #[cfg(not(target_arch = "wasm32"))] 102 pub unsafe fn context_get() -> u32 { 103 unreachable!() 104 } 105 106 #[cfg(target_arch = "wasm32")] 107 #[link(wasm_import_module = "$root")] 108 unsafe extern "C" { 109 #[link_name = "[context-set-0]"] 110 pub fn context_set(value: u32); 111 } 112 #[cfg(not(target_arch = "wasm32"))] 113 pub unsafe fn context_set(_: u32) { 114 unreachable!() 115 } 116 117 #[cfg(target_arch = "wasm32")] 118 #[link(wasm_import_module = "[export]$root")] 119 unsafe extern "C" { 120 #[link_name = "[task-cancel]"] 121 pub fn task_cancel(); 122 } 123 #[cfg(not(target_arch = "wasm32"))] 124 pub unsafe extern "C" fn task_cancel() { 125 unreachable!() 126 } 127 128 #[cfg(target_arch = "wasm32")] 129 #[link(wasm_import_module = "$root")] 130 unsafe extern "C" { 131 #[link_name = "[thread-yield]"] 132 pub fn thread_yield() -> u32; 133 } 134 #[cfg(not(target_arch = "wasm32"))] 135 pub unsafe fn thread_yield() -> u32 { 136 unreachable!() 137 } 138 139 pub const STATUS_STARTING: u32 = 0; 140 pub const STATUS_STARTED: u32 = 1; 141 pub const STATUS_RETURNED: u32 = 2; 142 pub const STATUS_START_CANCELLED: u32 = 3; 143 pub const STATUS_RETURN_CANCELLED: u32 = 4; 144 145 pub const EVENT_NONE: u32 = 0; 146 pub const EVENT_SUBTASK: u32 = 1; 147 pub const EVENT_STREAM_READ: u32 = 2; 148 pub const EVENT_STREAM_WRITE: u32 = 3; 149 pub const EVENT_FUTURE_READ: u32 = 4; 150 pub const EVENT_FUTURE_WRITE: u32 = 5; 151 pub const EVENT_CANCELLED: u32 = 6; 152 153 pub const CALLBACK_CODE_EXIT: u32 = 0; 154 pub const CALLBACK_CODE_YIELD: u32 = 1; 155 pub const CALLBACK_CODE_WAIT: u32 = 2; 156 157 pub const BLOCKED: u32 = 0xffff_ffff; 158 pub const DROPPED: u32 = 1; 159 pub const COMPLETED: u32 = 0; 160 161 pub const SUSPEND_RESULT_NOT_CANCELLED: u32 = 0; 162 pub const SUSPEND_RESULT_CANCELLED: u32 = 1; 163