#![no_main] #![cfg_attr(target_os = "none", no_std)] use core::sync::atomic::{AtomicUsize, Ordering}; const ITERATIONS: usize = 100; rt::once!(ONCE); rt::sem!(SEM); static X: AtomicUsize = AtomicUsize::new(0); fn f() { X.fetch_add(1, Ordering::Relaxed); } fn oncer() { rt::task::drop_privilege(); for _ in 0..ITERATIONS { ONCE.call_once(f); } } fn oncer_trap() { oncer(); assert_eq!( X.load(Ordering::Relaxed), 1, "X did not have the expected value" ); rt::trap(); } const STACK_SIZE: usize = rt::stack::MIN * 8; rt::task!(oncer, rt::stack::MIN, 0); rt::task!(oncer_trap, STACK_SIZE, 0);