1use crate::env;
2use crate::sync::atomic::{self, Ordering};
3use crate::sys::thread as imp;
4
5pub fn min_stack() -> usize {
6 static MIN: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
7 match MIN.load(order:Ordering::Relaxed) {
8 0 => {}
9 n: usize => return n - 1,
10 }
11 let amt: Option = env::var_os(key:"RUST_MIN_STACK").and_then(|s: OsString| s.to_str().and_then(|s: &str| s.parse().ok()));
12 let amt: usize = amt.unwrap_or(imp::DEFAULT_MIN_STACK_SIZE);
13
14 // 0 is our sentinel value, so ensure that we'll never see 0 after
15 // initialization has run
16 MIN.store(val:amt + 1, order:Ordering::Relaxed);
17 amt
18}
19