diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-12-10 17:22:10 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-12-10 18:16:22 -0800 |
| commit | 3fcdb7d6a758ac4ed1f27fcda77c372edaab4c09 (patch) | |
| tree | de69a4a3cf7eef65c15ba3858df96220194e778e /src/libcore | |
| parent | ed686aeac4c717a85175a0f3b63d3ff50c2f50a7 (diff) | |
Adjust the die macro to only accept ~str and to work in statement position
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/rt.rs | 9 | ||||
| -rw-r--r-- | src/libcore/sys.rs | 29 |
2 files changed, 29 insertions, 9 deletions
diff --git a/src/libcore/rt.rs b/src/libcore/rt.rs index f4e3463f0b7..120103bd656 100644 --- a/src/libcore/rt.rs +++ b/src/libcore/rt.rs @@ -27,9 +27,6 @@ pub type rust_task = c_void; extern mod rustrt { #[rust_stack] - fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t); - - #[rust_stack] fn rust_upcall_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char; #[rust_stack] @@ -47,11 +44,7 @@ extern mod rustrt { // gather_rust_rtcalls. #[rt(fail_)] pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! { - unsafe { - cleanup_stack_for_failure(); - rustrt::rust_upcall_fail(expr, file, line); - cast::transmute(()) - } + sys::begin_unwind_(expr, file, line); } #[rt(fail_bounds_check)] diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 7d5d644719f..62ced601951 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -15,7 +15,7 @@ #[forbid(deprecated_pattern)]; use cmp::{Eq, Ord}; -use libc::c_void; +use libc::{c_void, c_char, size_t}; pub type FreeGlue = fn(*TypeDesc, *c_void); @@ -43,6 +43,11 @@ extern mod rusti { fn min_align_of<T>() -> uint; } +extern mod rustrt { + #[rust_stack] + fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t); +} + /// Compares contents of two pointers using the default method. /// Equivalent to `*x1 == *x2`. Useful for hashtables. pub pure fn shape_eq<T:Eq>(x1: &T, x2: &T) -> bool { @@ -108,6 +113,28 @@ pub pure fn log_str<T>(t: &T) -> ~str { } } +/** Initiate task failure */ +pub pure fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! { + do str::as_buf(msg) |msg_buf, _msg_len| { + do str::as_buf(file) |file_buf, _file_len| { + unsafe { + let msg_buf = cast::transmute(msg_buf); + let file_buf = cast::transmute(file_buf); + begin_unwind_(msg_buf, file_buf, line as libc::size_t) + } + } + } +} + +// XXX: Temorary until rt::rt_fail_ goes away +pub pure fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { + unsafe { + gc::cleanup_stack_for_failure(); + rustrt::rust_upcall_fail(msg, file, line); + cast::transmute(()) + } +} + #[cfg(test)] pub mod tests { |
