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::FromStr;
14 use libc::{size_t, c_char, c_int};
15 use option::{Some, None};
20 pub struct Environment {
21 /// The number of threads to use by default
22 num_sched_threads: size_t,
23 /// The minimum size of a stack segment
24 min_stack_size: size_t,
25 /// The maximum amount of total stack per task before aborting
26 max_stack_size: size_t,
27 /// The default logging configuration
29 /// Record and report detailed information about memory leaks
31 /// Seed the random number generator
33 /// Poison allocations on free
35 /// The argc value passed to main
37 /// The argv value passed to main
39 /// Print GC debugging info (true if env var RUST_DEBUG_MEM is set)
41 /// Print GC debugging info (true if env var RUST_DEBUG_BORROW is set)
45 /// Get the global environment settings
47 /// This will abort the process if run outside of task context
48 pub fn get() -> &Environment {
49 unsafe { rust_get_rt_env() }
53 fn rust_get_rt_env() -> &Environment;
58 // Note that these are all accessed without any synchronization.
59 // They are expected to be initialized once then left alone.
61 static mut MIN_STACK: uint = 2000000;
65 match os::getenv("RUST_MIN_STACK") {
66 Some(s) => match FromStr::from_str(s) {
67 Some(i) => MIN_STACK = i,
75 pub fn min_stack() -> uint {