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);
}
#[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)
}
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,
/// _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<()> {
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| {
-// 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__)