1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Runtime environment settings
13 use from_str::from_str;
14 use option::{Some, None};
18 // Note that these are all accessed without any synchronization.
19 // They are expected to be initialized once then left alone.
21 static mut MIN_STACK: uint = 2 * 1024 * 1024;
22 /// This default corresponds to 20M of cache per scheduler (at the default size).
23 static mut MAX_CACHED_STACKS: uint = 10;
24 static mut DEBUG_BORROW: bool = false;
28 match os::getenv("RUST_MIN_STACK") {
29 Some(s) => match from_str(s.as_slice()) {
30 Some(i) => MIN_STACK = i,
35 match os::getenv("RUST_MAX_CACHED_STACKS") {
38 from_str(max.as_slice()).expect("expected positive \
40 RUST_MAX_CACHED_STACKS")
44 match os::getenv("RUST_DEBUG_BORROW") {
45 Some(_) => DEBUG_BORROW = true,
51 pub fn min_stack() -> uint {
55 pub fn max_cached_stacks() -> uint {
56 unsafe { MAX_CACHED_STACKS }
59 pub fn debug_borrow() -> bool {
60 unsafe { DEBUG_BORROW }