@@ -48,9 +48,7 @@ impl Frame {
48
48
Frame :: Raw ( ctx) => ctx,
49
49
Frame :: Cloned { ip, .. } => return ip,
50
50
} ;
51
- unsafe {
52
- uw:: _Unwind_GetIP ( ctx) as * mut c_void
53
- }
51
+ unsafe { uw:: _Unwind_GetIP ( ctx) as * mut c_void }
54
52
}
55
53
56
54
pub fn symbol_address ( & self ) -> * mut c_void {
@@ -87,8 +85,10 @@ impl Clone for Frame {
87
85
pub unsafe fn trace ( mut cb : & mut FnMut ( & super :: Frame ) -> bool ) {
88
86
uw:: _Unwind_Backtrace ( trace_fn, & mut cb as * mut _ as * mut _ ) ;
89
87
90
- extern fn trace_fn ( ctx : * mut uw:: _Unwind_Context ,
91
- arg : * mut c_void ) -> uw:: _Unwind_Reason_Code {
88
+ extern "C" fn trace_fn (
89
+ ctx : * mut uw:: _Unwind_Context ,
90
+ arg : * mut c_void ,
91
+ ) -> uw:: _Unwind_Reason_Code {
92
92
let cb = unsafe { & mut * ( arg as * mut & mut FnMut ( & super :: Frame ) -> bool ) } ;
93
93
let cx = super :: Frame {
94
94
inner : Frame :: Raw ( ctx) ,
@@ -136,36 +136,40 @@ mod uw {
136
136
pub enum _Unwind_Context { }
137
137
138
138
pub type _Unwind_Trace_Fn =
139
- extern fn ( ctx : * mut _Unwind_Context ,
140
- arg : * mut c_void ) -> _Unwind_Reason_Code ;
139
+ extern "C" fn ( ctx : * mut _Unwind_Context , arg : * mut c_void ) -> _Unwind_Reason_Code ;
141
140
142
- extern {
141
+ extern "C" {
143
142
// No native _Unwind_Backtrace on iOS
144
143
#[ cfg( not( all( target_os = "ios" , target_arch = "arm" ) ) ) ]
145
- pub fn _Unwind_Backtrace ( trace : _Unwind_Trace_Fn ,
146
- trace_argument : * mut c_void )
147
- -> _Unwind_Reason_Code ;
144
+ pub fn _Unwind_Backtrace (
145
+ trace : _Unwind_Trace_Fn ,
146
+ trace_argument : * mut c_void ,
147
+ ) -> _Unwind_Reason_Code ;
148
148
149
149
// available since GCC 4.2.0, should be fine for our purpose
150
- #[ cfg( all( not( all( target_os = "android" , target_arch = "arm" ) ) ,
151
- not( all( target_os = "freebsd" , target_arch = "arm" ) ) ,
152
- not( all( target_os = "linux" , target_arch = "arm" ) ) ) ) ]
153
- pub fn _Unwind_GetIP ( ctx : * mut _Unwind_Context )
154
- -> libc:: uintptr_t ;
155
-
156
- #[ cfg( all( not( target_os = "android" ) ,
157
- not( all( target_os = "freebsd" , target_arch = "arm" ) ) ,
158
- not( all( target_os = "linux" , target_arch = "arm" ) ) ) ) ]
159
- pub fn _Unwind_FindEnclosingFunction ( pc : * mut c_void )
160
- -> * mut c_void ;
150
+ #[ cfg( all(
151
+ not( all( target_os = "android" , target_arch = "arm" ) ) ,
152
+ not( all( target_os = "freebsd" , target_arch = "arm" ) ) ,
153
+ not( all( target_os = "linux" , target_arch = "arm" ) )
154
+ ) ) ]
155
+ pub fn _Unwind_GetIP ( ctx : * mut _Unwind_Context ) -> libc:: uintptr_t ;
156
+
157
+ #[ cfg( all(
158
+ not( target_os = "android" ) ,
159
+ not( all( target_os = "freebsd" , target_arch = "arm" ) ) ,
160
+ not( all( target_os = "linux" , target_arch = "arm" ) )
161
+ ) ) ]
162
+ pub fn _Unwind_FindEnclosingFunction ( pc : * mut c_void ) -> * mut c_void ;
161
163
}
162
164
163
165
// On android, the function _Unwind_GetIP is a macro, and this is the
164
166
// expansion of the macro. This is all copy/pasted directly from the
165
167
// header file with the definition of _Unwind_GetIP.
166
- #[ cfg( any( all( target_os = "android" , target_arch = "arm" ) ,
167
- all( target_os = "freebsd" , target_arch = "arm" ) ,
168
- all( target_os = "linux" , target_arch = "arm" ) ) ) ]
168
+ #[ cfg( any(
169
+ all( target_os = "android" , target_arch = "arm" ) ,
170
+ all( target_os = "freebsd" , target_arch = "arm" ) ,
171
+ all( target_os = "linux" , target_arch = "arm" )
172
+ ) ) ]
169
173
pub unsafe fn _Unwind_GetIP ( ctx : * mut _Unwind_Context ) -> libc:: uintptr_t {
170
174
#[ repr( C ) ]
171
175
enum _Unwind_VRS_Result {
@@ -192,33 +196,36 @@ mod uw {
192
196
}
193
197
194
198
type _Unwind_Word = libc:: c_uint ;
195
- extern {
196
- fn _Unwind_VRS_Get ( ctx : * mut _Unwind_Context ,
197
- klass : _Unwind_VRS_RegClass ,
198
- word : _Unwind_Word ,
199
- repr : _Unwind_VRS_DataRepresentation ,
200
- data : * mut c_void )
201
- -> _Unwind_VRS_Result ;
199
+ extern "C" {
200
+ fn _Unwind_VRS_Get (
201
+ ctx : * mut _Unwind_Context ,
202
+ klass : _Unwind_VRS_RegClass ,
203
+ word : _Unwind_Word ,
204
+ repr : _Unwind_VRS_DataRepresentation ,
205
+ data : * mut c_void ,
206
+ ) -> _Unwind_VRS_Result ;
202
207
}
203
208
204
209
let mut val: _Unwind_Word = 0 ;
205
210
let ptr = & mut val as * mut _Unwind_Word ;
206
- let _ = _Unwind_VRS_Get ( ctx, _Unwind_VRS_RegClass:: _UVRSC_CORE, 15 ,
207
- _Unwind_VRS_DataRepresentation:: _UVRSD_UINT32,
208
- ptr as * mut c_void ) ;
211
+ let _ = _Unwind_VRS_Get (
212
+ ctx,
213
+ _Unwind_VRS_RegClass:: _UVRSC_CORE,
214
+ 15 ,
215
+ _Unwind_VRS_DataRepresentation:: _UVRSD_UINT32,
216
+ ptr as * mut c_void ,
217
+ ) ;
209
218
( val & !1 ) as libc:: uintptr_t
210
219
}
211
220
212
221
// This function also doesn't exist on Android or ARM/Linux, so make it
213
222
// a no-op
214
- #[ cfg( any( target_os = "android" ,
215
- all ( target_os = "freebsd" , target_arch = "arm" ) ,
216
- all( target_os = "linux " , target_arch = "arm" ) ) ) ]
217
- pub unsafe fn _Unwind_FindEnclosingFunction ( pc : * mut c_void )
218
- -> * mut c_void
219
- {
223
+ #[ cfg( any(
224
+ target_os = "android" ,
225
+ all( target_os = "freebsd " , target_arch = "arm" ) ,
226
+ all ( target_os = "linux" , target_arch = "arm" )
227
+ ) ) ]
228
+ pub unsafe fn _Unwind_FindEnclosingFunction ( pc : * mut c_void ) -> * mut c_void {
220
229
pc
221
230
}
222
231
}
223
-
224
-
0 commit comments