From ebc6474668ec60cc793af0f48143bf33d984deb4 Mon Sep 17 00:00:00 2001 From: Valerii Hiora Date: Fri, 13 Jun 2014 10:18:12 +0300 Subject: [PATCH] Cosmetic fixes & comments --- src/librustrt/libunwind.rs | 12 ++++++------ src/librustrt/unwind.rs | 1 - src/libstd/rt/backtrace.rs | 11 ++++++++--- src/rt/arch/arm/record_sp.S | 6 +++++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/librustrt/libunwind.rs b/src/librustrt/libunwind.rs index 50c2aba2b5cb..2d58c1bee15b 100644 --- a/src/librustrt/libunwind.rs +++ b/src/librustrt/libunwind.rs @@ -97,10 +97,14 @@ extern {} extern "C" { // iOS on armv7 uses SjLj exceptions and requires to link // agains corresponding routine (..._SjLj_...) - // So here we just skip linking for iOS #[cfg(not(target_os = "ios", target_arch = "arm"))] pub fn _Unwind_RaiseException(exception: *_Unwind_Exception) - -> _Unwind_Reason_Code; + -> _Unwind_Reason_Code; + + #[cfg(target_os = "ios", target_arch = "arm")] + fn _Unwind_SjLj_RaiseException(e: *_Unwind_Exception) + -> _Unwind_Reason_Code; + pub fn _Unwind_DeleteException(exception: *_Unwind_Exception); } @@ -111,9 +115,5 @@ extern "C" { #[inline(always)] pub unsafe fn _Unwind_RaiseException(exc: *_Unwind_Exception) -> _Unwind_Reason_Code { - extern "C" { - fn _Unwind_SjLj_RaiseException(e: *_Unwind_Exception) - -> _Unwind_Reason_Code; } - _Unwind_SjLj_RaiseException(exc) } diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index e60c50f0adb4..5b941c9d5aa3 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -303,7 +303,6 @@ pub mod eabi { use libc::c_int; extern "C" { - #[cfg(target_os = "ios", target_arch = "arm")] fn __gcc_personality_sj0(version: c_int, actions: uw::_Unwind_Action, exception_class: uw::_Unwind_Exception_Class, diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 16b598b3ae7b..0e3e7cc796a3 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -248,6 +248,11 @@ mod imp { /// _Unwind_Backtrace is even not available there. Still, /// backtraces could be extracted using a backtrace function, /// which thanks god is public + /// + /// As mentioned in a huge comment block above, backtrace doesn't + /// play well with green threads, so while it is extremely nice + /// and simple to use it should be used only on iOS devices as the + /// only viable option. #[cfg(target_os = "ios", target_arch = "arm")] #[inline(never)] pub fn write(w: &mut Writer) -> IoResult<()> { @@ -267,9 +272,9 @@ mod imp { try!(writeln!(w, "stack backtrace:")); // 100 lines should be enough - static size: libc::c_int = 100; - let mut buf: [*libc::c_void, ..size] = unsafe {mem::zeroed()}; - let cnt = unsafe { backtrace(buf.as_mut_ptr(), size) as uint}; + static SIZE: libc::c_int = 100; + let mut buf: [*libc::c_void, ..SIZE] = unsafe {mem::zeroed()}; + let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE) as uint}; // skipping the first one as it is write itself result::fold_(range(1, cnt).map(|i| { diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S index 94cfcff039e4..d0e9b81b95a9 100644 --- a/src/rt/arch/arm/record_sp.S +++ b/src/rt/arch/arm/record_sp.S @@ -1,4 +1,8 @@ -// Do not compile anything here for iOS +// Do not compile anything here for iOS because split stacks +// are disabled at all and do not need any runtime support. +// +// See also comments in librustrt/stack.rs about why it was +// disabled and how it could be implemented in case of need. #if !defined(__APPLE__) // Mark stack as non-executable #if defined(__linux__) && defined(__ELF__)