about summary refs log tree commit diff
path: root/src/libstd/sys.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-07-31 23:12:20 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-09 16:45:50 -0700
commitb75915d0ca20c6d066a7368ad53491a55a5a57d2 (patch)
treed4f4a08c262940345b2cd5a1a223772f6aefb985 /src/libstd/sys.rs
parentd39255616004ea43dfabcf33b20ed2a80cd31dff (diff)
downloadrust-b75915d0ca20c6d066a7368ad53491a55a5a57d2.tar.gz
rust-b75915d0ca20c6d066a7368ad53491a55a5a57d2.zip
Remove the C++ runtime. Sayonara
Diffstat (limited to 'src/libstd/sys.rs')
-rw-r--r--src/libstd/sys.rs80
1 files changed, 30 insertions, 50 deletions
diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs
index 15c096ad04f..cf34bd3261a 100644
--- a/src/libstd/sys.rs
+++ b/src/libstd/sys.rs
@@ -21,15 +21,6 @@ use str::StrSlice;
 use str;
 use unstable::intrinsics;
 
-pub mod rustrt {
-    use libc::{c_char, size_t};
-
-    extern {
-        #[rust_stack]
-        pub fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t);
-    }
-}
-
 /// Returns the size of a type
 #[inline]
 pub fn size_of<T>() -> uint {
@@ -136,55 +127,44 @@ impl FailWithCause for &'static str {
 pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
     use either::Left;
     use option::{Some, None};
-    use rt::{context, OldTaskContext, in_green_task_context};
+    use rt::in_green_task_context;
     use rt::task::Task;
     use rt::local::Local;
     use rt::logging::Logger;
     use str::Str;
 
-    let context = context();
-    match context {
-        OldTaskContext => {
-            unsafe {
-                rustrt::rust_upcall_fail(msg, file, line);
-                cast::transmute(())
+    unsafe {
+        // XXX: Bad re-allocations. fail! needs some refactoring
+        let msg = str::raw::from_c_str(msg);
+        let file = str::raw::from_c_str(file);
+
+        // XXX: Logging doesn't work correctly in non-task context because it
+        // invokes the local heap
+        if in_green_task_context() {
+            // XXX: Logging doesn't work here - the check to call the log
+            // function never passes - so calling the log function directly.
+            do Local::borrow::<Task, ()> |task| {
+                let msg = match task.name {
+                    Some(ref name) =>
+                    fmt!("task '%s' failed at '%s', %s:%i",
+                         name.as_slice(), msg, file, line as int),
+                    None =>
+                    fmt!("task <unnamed> failed at '%s', %s:%i",
+                         msg, file, line as int)
+                };
+
+                task.logger.log(Left(msg));
             }
+        } else {
+            rterrln!("failed in non-task context at '%s', %s:%i",
+                     msg, file, line as int);
         }
-        _ => {
-            unsafe {
-                // XXX: Bad re-allocations. fail! needs some refactoring
-                let msg = str::raw::from_c_str(msg);
-                let file = str::raw::from_c_str(file);
-
-                // XXX: Logging doesn't work correctly in non-task context because it
-                // invokes the local heap
-                if in_green_task_context() {
-                    // XXX: Logging doesn't work here - the check to call the log
-                    // function never passes - so calling the log function directly.
-                    do Local::borrow::<Task, ()> |task| {
-                        let msg = match task.name {
-                            Some(ref name) =>
-                                fmt!("task '%s' failed at '%s', %s:%i",
-                                     name.as_slice(), msg, file, line as int),
-                            None =>
-                                fmt!("task <unnamed> failed at '%s', %s:%i",
-                                     msg, file, line as int)
-                        };
-
-                        task.logger.log(Left(msg));
-                    }
-                } else {
-                    rterrln!("failed in non-task context at '%s', %s:%i",
-                             msg, file, line as int);
-                }
-
-                let task = Local::unsafe_borrow::<Task>();
-                if (*task).unwinder.unwinding {
-                    rtabort!("unwinding again");
-                }
-                (*task).unwinder.begin_unwind();
-            }
+
+        let task = Local::unsafe_borrow::<Task>();
+        if (*task).unwinder.unwinding {
+            rtabort!("unwinding again");
         }
+        (*task).unwinder.begin_unwind();
     }
 }