about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-16 14:27:44 -0700
committerbors <bors@rust-lang.org>2013-03-16 14:27:44 -0700
commitb53da4b9dd977fdffba3f10e570d7c025238dec3 (patch)
treeffba2f796ce9bb6e36c1d083553db7bc9638f0be /src/libcore
parentebba8b4e3591c95508a4c1121784e768272a574a (diff)
parent63d18658c1d19bdcc4cad91ce808a9590b53f3d2 (diff)
downloadrust-b53da4b9dd977fdffba3f10e570d7c025238dec3.tar.gz
rust-b53da4b9dd977fdffba3f10e570d7c025238dec3.zip
auto merge of #5342 : brson/rust/debug-mem, r=brson
Fixes #5341
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/cleanup.rs6
-rw-r--r--src/libcore/rt/env.rs47
-rw-r--r--src/libcore/rt/mod.rs1
3 files changed, 49 insertions, 5 deletions
diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs
index faa6db45df2..a46e9154703 100644
--- a/src/libcore/cleanup.rs
+++ b/src/libcore/cleanup.rs
@@ -145,11 +145,7 @@ unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
 
 #[cfg(unix)]
 fn debug_mem() -> bool {
-    use os;
-    use libc;
-    do os::as_c_charp("RUST_DEBUG_MEM") |p| {
-        unsafe { libc::getenv(p) != null() }
-    }
+    ::rt::env::get().debug_mem
 }
 
 #[cfg(windows)]
diff --git a/src/libcore/rt/env.rs b/src/libcore/rt/env.rs
new file mode 100644
index 00000000000..008e31777b0
--- /dev/null
+++ b/src/libcore/rt/env.rs
@@ -0,0 +1,47 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Runtime environment settings
+
+use libc::{size_t, c_char, c_int};
+
+pub struct Environment {
+    /// The number of threads to use by default
+    num_sched_threads: size_t,
+    /// The minimum size of a stack segment
+    min_stack_size: size_t,
+    /// The maximum amount of total stack per task before aborting
+    max_stack_size: size_t,
+    /// The default logging configuration
+    logspec: *c_char,
+    /// Record and report detailed information about memory leaks
+    detailed_leaks: bool,
+    /// Seed the random number generator
+    rust_seed: *c_char,
+    /// Poison allocations on free
+    poison_on_free: bool,
+    /// The argc value passed to main
+    argc: c_int,
+    /// The argv value passed to main
+    argv: **c_char,
+    /// Print GC debugging info
+    debug_mem: bool
+}
+
+/// Get the global environment settings
+/// # Safety Note
+/// This will abort the process if run outside of task context
+pub fn get() -> &Environment {
+    unsafe { rust_get_rt_env() }
+}
+
+extern {
+    fn rust_get_rt_env() -> &Environment;
+}
\ No newline at end of file
diff --git a/src/libcore/rt/mod.rs b/src/libcore/rt/mod.rs
index ea3878adbf0..a1a9884aeca 100644
--- a/src/libcore/rt/mod.rs
+++ b/src/libcore/rt/mod.rs
@@ -45,3 +45,4 @@ mod work_queue;
 mod stack;
 mod context;
 mod thread;
+pub mod env;