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.
4+ //
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.
10+
11+ //! Runtime environment settings
12+
13+ use libc:: { size_t, c_char, c_int} ;
14+
15+ pub struct Environment {
16+ /// The number of threads to use by default
17+ num_sched_threads : size_t ,
18+ /// The minimum size of a stack segment
19+ min_stack_size : size_t ,
20+ /// The maximum amount of total stack per task before aborting
21+ max_stack_size : size_t ,
22+ /// The default logging configuration
23+ logspec : * c_char ,
24+ /// Record and report detailed information about memory leaks
25+ detailed_leaks : bool ,
26+ /// Seed the random number generator
27+ rust_seed : * c_char ,
28+ /// Poison allocations on free
29+ poison_on_free : bool ,
30+ /// The argc value passed to main
31+ argc : c_int ,
32+ /// The argv value passed to main
33+ argv : * * c_char ,
34+ /// Print GC debugging info
35+ debug_mem : bool
36+ }
37+
38+ /// Get the global environment settings
39+ /// # Safety Note
40+ /// This will abort the process if run outside of task context
41+ pub fn get ( ) -> & Environment {
42+ unsafe { rust_get_rt_env ( ) }
43+ }
44+
45+ extern {
46+ fn rust_get_rt_env ( ) -> & Environment ;
47+ }
0 commit comments