12264f72aSAlex Crichton use test_programs::p3::wasi as wasip3; 22264f72aSAlex Crichton 3*5d3627b7SBailey Hayes #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15")] 42264f72aSAlex Crichton unsafe extern "C" { 52264f72aSAlex Crichton #[link_name = "[async-lower]wait-for"] wait_for(dur: u64) -> u3262264f72aSAlex Crichton fn wait_for(dur: u64) -> u32; 72264f72aSAlex Crichton } 82264f72aSAlex Crichton 92264f72aSAlex Crichton struct Component; 102264f72aSAlex Crichton 112264f72aSAlex Crichton test_programs::p3::export!(Component); 122264f72aSAlex Crichton 132264f72aSAlex Crichton impl test_programs::p3::exports::wasi::cli::run::Guest for Component { run() -> Result<(), ()>142264f72aSAlex Crichton async fn run() -> Result<(), ()> { 152264f72aSAlex Crichton // Execute it once to ensure we get type information pulled in. 162264f72aSAlex Crichton wasip3::clocks::monotonic_clock::wait_for(0).await; 172264f72aSAlex Crichton 182264f72aSAlex Crichton // Execute the raw function without Rust bindings to stress invoking it 192264f72aSAlex Crichton // many times. 202264f72aSAlex Crichton for _ in 0..1000 { 212264f72aSAlex Crichton unsafe { 222264f72aSAlex Crichton wait_for(1 << 60); 232264f72aSAlex Crichton } 242264f72aSAlex Crichton } 252264f72aSAlex Crichton 262264f72aSAlex Crichton panic!("should have trapped before now"); 272264f72aSAlex Crichton } 282264f72aSAlex Crichton } 292264f72aSAlex Crichton main()302264f72aSAlex Crichtonfn main() { 312264f72aSAlex Crichton unreachable!(); 322264f72aSAlex Crichton } 33