diff options
| author | Fenrir <[email protected]> | 2017-08-01 15:24:05 -0600 |
|---|---|---|
| committer | Fenrir <[email protected]> | 2017-08-01 15:24:05 -0600 |
| commit | b2ba0fa9af69b7ff12b68e1c8b1f2c923c455e2e (patch) | |
| tree | 200404e7ea82f6db3456cbe76f3542407da99037 /ctr-std/src/rt.rs | |
| parent | Update pinned nightly to 2017-07-31 (diff) | |
| download | ctru-rs-b2ba0fa9af69b7ff12b68e1c8b1f2c923c455e2e.tar.xz ctru-rs-b2ba0fa9af69b7ff12b68e1c8b1f2c923c455e2e.zip | |
Properly set up main thread
Diffstat (limited to 'ctr-std/src/rt.rs')
| -rw-r--r-- | ctr-std/src/rt.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ctr-std/src/rt.rs b/ctr-std/src/rt.rs index ddfb707..735509b 100644 --- a/ctr-std/src/rt.rs +++ b/ctr-std/src/rt.rs @@ -23,6 +23,8 @@ #![doc(hidden)] use panic; +use sys_common::thread_info; +use thread::Thread; use mem; // Reexport some of our utilities which are expected by other crates. @@ -32,8 +34,19 @@ pub use panicking::{begin_panic, begin_panic_fmt}; #[lang = "start"] #[allow(unused_variables)] fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize { - let _ = unsafe { - panic::catch_unwind(mem::transmute::<_, fn()>(main)) + let failed = unsafe { + let thread = Thread::new(Some("main".to_owned())); + + thread_info::set(None, thread); + + let res = panic::catch_unwind(mem::transmute::<_, fn()>(main)); + + res.is_err() }; - 0 + + if failed { + 101 + } else { + 0 + } } |