|
15 | 15 | #[forbid(deprecated_pattern)];
|
16 | 16 |
|
17 | 17 | use cmp::{Eq, Ord};
|
18 |
| -use libc::c_void; |
| 18 | +use libc::{c_void, c_char, size_t}; |
19 | 19 |
|
20 | 20 | pub type FreeGlue = fn(*TypeDesc, *c_void);
|
21 | 21 |
|
@@ -43,6 +43,11 @@ extern mod rusti {
|
43 | 43 | fn min_align_of<T>() -> uint;
|
44 | 44 | }
|
45 | 45 |
|
| 46 | +extern mod rustrt { |
| 47 | + #[rust_stack] |
| 48 | + fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t); |
| 49 | +} |
| 50 | + |
46 | 51 | /// Compares contents of two pointers using the default method.
|
47 | 52 | /// Equivalent to `*x1 == *x2`. Useful for hashtables.
|
48 | 53 | 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 {
|
108 | 113 | }
|
109 | 114 | }
|
110 | 115 |
|
| 116 | +/** Initiate task failure */ |
| 117 | +pub pure fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! { |
| 118 | + do str::as_buf(msg) |msg_buf, _msg_len| { |
| 119 | + do str::as_buf(file) |file_buf, _file_len| { |
| 120 | + unsafe { |
| 121 | + let msg_buf = cast::transmute(msg_buf); |
| 122 | + let file_buf = cast::transmute(file_buf); |
| 123 | + begin_unwind_(msg_buf, file_buf, line as libc::size_t) |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +// XXX: Temorary until rt::rt_fail_ goes away |
| 130 | +pub pure fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { |
| 131 | + unsafe { |
| 132 | + gc::cleanup_stack_for_failure(); |
| 133 | + rustrt::rust_upcall_fail(msg, file, line); |
| 134 | + cast::transmute(()) |
| 135 | + } |
| 136 | +} |
| 137 | + |
111 | 138 | #[cfg(test)]
|
112 | 139 | pub mod tests {
|
113 | 140 |
|
|
0 commit comments