about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/mod.rs40
-rw-r--r--src/libstd/rt/unwind/mod.rs4
2 files changed, 2 insertions, 42 deletions
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 56bf73db399..24a4575aa54 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -23,7 +23,7 @@
 
 use prelude::v1::*;
 use sys;
-use usize;
+use thread;
 
 // Reexport some of our utilities which are expected by other crates.
 pub use self::util::min_stack;
@@ -53,11 +53,6 @@ mod dwarf;
 /// of exiting cleanly.
 pub const DEFAULT_ERROR_CODE: isize = 101;
 
-#[cfg(any(windows, android))]
-const OS_DEFAULT_STACK_ESTIMATE: usize = 1 << 20;
-#[cfg(all(unix, not(android)))]
-const OS_DEFAULT_STACK_ESTIMATE: usize = 2 * (1 << 20);
-
 #[cfg(not(test))]
 #[lang = "start"]
 fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
@@ -67,37 +62,9 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
     use env;
     use rt;
     use sys_common::thread_info::{self, NewThread};
-    use sys_common;
     use thread::Thread;
 
-    let something_around_the_top_of_the_stack = 1;
-    let addr = &something_around_the_top_of_the_stack as *const _ as *const isize;
-    let my_stack_top = addr as usize;
-
-    // FIXME #11359 we just assume that this thread has a stack of a
-    // certain size, and estimate that there's at most 20KB of stack
-    // frames above our current position.
-    const TWENTY_KB: usize = 20000;
-
-    // saturating-add to sidestep overflow
-    let top_plus_spill = if usize::MAX - TWENTY_KB < my_stack_top {
-        usize::MAX
-    } else {
-        my_stack_top + TWENTY_KB
-    };
-    // saturating-sub to sidestep underflow
-    let my_stack_bottom = if top_plus_spill < OS_DEFAULT_STACK_ESTIMATE {
-        0
-    } else {
-        top_plus_spill - OS_DEFAULT_STACK_ESTIMATE
-    };
-
     let failed = unsafe {
-        // First, make sure we don't trigger any __morestack overflow checks,
-        // and next set up our stack to have a guard page and run through our
-        // own fault handlers if we hit it.
-        sys_common::stack::record_os_managed_stack_bounds(my_stack_bottom,
-                                                          my_stack_top);
         let main_guard = sys::thread::guard::init();
         sys::stack_overflow::init();
 
@@ -129,10 +96,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
         args::init(argc, argv);
 
         // And finally, let's run some code!
-        let res = unwind::try(|| {
-            let main: fn() = mem::transmute(main);
-            main();
-        });
+        let res = thread::catch_panic(mem::transmute::<_, fn()>(main));
         cleanup();
         res.is_err()
     };
diff --git a/src/libstd/rt/unwind/mod.rs b/src/libstd/rt/unwind/mod.rs
index 59b2e14643d..bb43eec8db1 100644
--- a/src/libstd/rt/unwind/mod.rs
+++ b/src/libstd/rt/unwind/mod.rs
@@ -111,10 +111,6 @@ static CALLBACK_CNT: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
 
 thread_local! { static PANICKING: Cell<bool> = Cell::new(false) }
 
-#[link(name = "rustrt_native", kind = "static")]
-#[cfg(not(test))]
-extern {}
-
 /// Invoke a closure, capturing the cause of panic if one occurs.
 ///
 /// This function will return `Ok(())` if the closure did not panic, and will