1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Unwind library interface
13 #![allow(non_camel_case_types)]
14 #![allow(non_snake_case_functions)]
15 #![allow(dead_code)] // these are just bindings
19 #[cfg(not(target_arch = "arm"))]
20 #[cfg(target_os = "ios")]
22 pub enum _Unwind_Action {
24 _UA_CLEANUP_PHASE = 2,
25 _UA_HANDLER_FRAME = 4,
27 _UA_END_OF_STACK = 16,
30 #[cfg(target_arch = "arm")]
32 pub enum _Unwind_State {
33 _US_VIRTUAL_UNWIND_FRAME = 0,
34 _US_UNWIND_FRAME_STARTING = 1,
35 _US_UNWIND_FRAME_RESUME = 2,
42 pub enum _Unwind_Reason_Code {
44 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
45 _URC_FATAL_PHASE2_ERROR = 2,
46 _URC_FATAL_PHASE1_ERROR = 3,
48 _URC_END_OF_STACK = 5,
49 _URC_HANDLER_FOUND = 6,
50 _URC_INSTALL_CONTEXT = 7,
51 _URC_CONTINUE_UNWIND = 8,
52 _URC_FAILURE = 9, // used only by ARM EABI
55 pub type _Unwind_Exception_Class = u64;
57 pub type _Unwind_Word = libc::uintptr_t;
59 #[cfg(target_arch = "x86")]
60 pub static unwinder_private_data_size: uint = 5;
62 #[cfg(target_arch = "x86_64")]
63 pub static unwinder_private_data_size: uint = 2;
65 #[cfg(target_arch = "arm", not(target_os = "ios"))]
66 pub static unwinder_private_data_size: uint = 20;
68 #[cfg(target_arch = "arm", target_os = "ios")]
69 pub static unwinder_private_data_size: uint = 5;
71 #[cfg(target_arch = "mips")]
72 #[cfg(target_arch = "mipsel")]
73 pub static unwinder_private_data_size: uint = 2;
75 pub struct _Unwind_Exception {
76 pub exception_class: _Unwind_Exception_Class,
77 pub exception_cleanup: _Unwind_Exception_Cleanup_Fn,
78 pub private: [_Unwind_Word, ..unwinder_private_data_size],
81 pub enum _Unwind_Context {}
83 pub type _Unwind_Exception_Cleanup_Fn =
84 extern "C" fn(unwind_code: _Unwind_Reason_Code,
85 exception: *mut _Unwind_Exception);
87 #[cfg(target_os = "linux")]
88 #[cfg(target_os = "freebsd")]
89 #[cfg(target_os = "win32")]
90 #[link(name = "gcc_s")]
93 #[cfg(target_os = "android")]
99 // iOS on armv7 uses SjLj exceptions and requires to link
100 // against corresponding routine (..._SjLj_...)
101 #[cfg(not(target_os = "ios", target_arch = "arm"))]
102 pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception)
103 -> _Unwind_Reason_Code;
105 #[cfg(target_os = "ios", target_arch = "arm")]
106 fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
107 -> _Unwind_Reason_Code;
109 pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception);
112 // ... and now we just providing access to SjLj counterspart
113 // through a standard name to hide those details from others
114 // (see also comment above regarding _Unwind_RaiseException)
115 #[cfg(target_os = "ios", target_arch = "arm")]
117 pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)
118 -> _Unwind_Reason_Code {
119 _Unwind_SjLj_RaiseException(exc)