Skip to content

Commit bc9725c

Browse files
committed
Indent some code inside cfg_select!
The previous code inside `cfg_if!` wasn't indented, so the conversion to `cfg_select!` left it not indented. Indent it.
1 parent 1ae4a0c commit bc9725c

File tree

1 file changed

+178
-174
lines changed

1 file changed

+178
-174
lines changed

library/unwind/src/libunwind.rs

Lines changed: 178 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -123,200 +123,204 @@ unsafe extern "C" {
123123
}
124124

125125
cfg_select! {
126-
any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "arm")) => {
127-
// Not ARM EHABI
128-
//
129-
// 32-bit ARM on iOS/tvOS/watchOS use either DWARF/Compact unwinding or
130-
// "setjmp-longjmp" / SjLj unwinding.
131-
pub type _Unwind_Action = c_int;
132-
133-
pub const _UA_SEARCH_PHASE: c_int = 1;
134-
pub const _UA_CLEANUP_PHASE: c_int = 2;
135-
pub const _UA_HANDLER_FRAME: c_int = 4;
136-
pub const _UA_FORCE_UNWIND: c_int = 8;
137-
pub const _UA_END_OF_STACK: c_int = 16;
138-
139-
#[cfg_attr(
140-
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
141-
link(name = "unwind", kind = "static", modifiers = "-bundle")
142-
)]
143-
unsafe extern "C" {
144-
pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word;
145-
pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word);
146-
pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word;
147-
pub fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word);
148-
pub fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ip_before_insn: *mut c_int)
149-
-> _Unwind_Word;
150-
pub fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void;
151-
}
126+
any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "arm")) => {
127+
// Not ARM EHABI
128+
//
129+
// 32-bit ARM on iOS/tvOS/watchOS use either DWARF/Compact unwinding or
130+
// "setjmp-longjmp" / SjLj unwinding.
131+
pub type _Unwind_Action = c_int;
132+
133+
pub const _UA_SEARCH_PHASE: c_int = 1;
134+
pub const _UA_CLEANUP_PHASE: c_int = 2;
135+
pub const _UA_HANDLER_FRAME: c_int = 4;
136+
pub const _UA_FORCE_UNWIND: c_int = 8;
137+
pub const _UA_END_OF_STACK: c_int = 16;
138+
139+
#[cfg_attr(
140+
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
141+
link(name = "unwind", kind = "static", modifiers = "-bundle")
142+
)]
143+
unsafe extern "C" {
144+
pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word;
145+
pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word);
146+
pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word;
147+
pub fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word);
148+
pub fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ip_before_insn: *mut c_int)
149+
-> _Unwind_Word;
150+
pub fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void;
151+
}
152152

153-
}
154-
_ => {
155-
// ARM EHABI
156-
#[repr(C)]
157-
#[derive(Copy, Clone, PartialEq)]
158-
pub enum _Unwind_State {
159-
_US_VIRTUAL_UNWIND_FRAME = 0,
160-
_US_UNWIND_FRAME_STARTING = 1,
161-
_US_UNWIND_FRAME_RESUME = 2,
162-
_US_ACTION_MASK = 3,
163-
_US_FORCE_UNWIND = 8,
164-
_US_END_OF_STACK = 16,
165153
}
166-
pub use _Unwind_State::*;
154+
_ => {
155+
// ARM EHABI
156+
#[repr(C)]
157+
#[derive(Copy, Clone, PartialEq)]
158+
pub enum _Unwind_State {
159+
_US_VIRTUAL_UNWIND_FRAME = 0,
160+
_US_UNWIND_FRAME_STARTING = 1,
161+
_US_UNWIND_FRAME_RESUME = 2,
162+
_US_ACTION_MASK = 3,
163+
_US_FORCE_UNWIND = 8,
164+
_US_END_OF_STACK = 16,
165+
}
166+
pub use _Unwind_State::*;
167167

168-
#[repr(C)]
169-
enum _Unwind_VRS_Result {
170-
_UVRSR_OK = 0,
171-
_UVRSR_NOT_IMPLEMENTED = 1,
172-
_UVRSR_FAILED = 2,
173-
}
174-
#[repr(C)]
175-
enum _Unwind_VRS_RegClass {
176-
_UVRSC_CORE = 0,
177-
_UVRSC_VFP = 1,
178-
_UVRSC_FPA = 2,
179-
_UVRSC_WMMXD = 3,
180-
_UVRSC_WMMXC = 4,
181-
}
182-
use _Unwind_VRS_RegClass::*;
183-
#[repr(C)]
184-
enum _Unwind_VRS_DataRepresentation {
185-
_UVRSD_UINT32 = 0,
186-
_UVRSD_VFPX = 1,
187-
_UVRSD_FPAX = 2,
188-
_UVRSD_UINT64 = 3,
189-
_UVRSD_FLOAT = 4,
190-
_UVRSD_DOUBLE = 5,
191-
}
192-
use _Unwind_VRS_DataRepresentation::*;
193-
194-
pub const UNWIND_POINTER_REG: c_int = 12;
195-
pub const UNWIND_SP_REG: c_int = 13;
196-
pub const UNWIND_IP_REG: c_int = 15;
197-
198-
#[cfg_attr(
199-
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
200-
link(name = "unwind", kind = "static", modifiers = "-bundle")
201-
)]
202-
unsafe extern "C" {
203-
fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
204-
regclass: _Unwind_VRS_RegClass,
205-
regno: _Unwind_Word,
206-
repr: _Unwind_VRS_DataRepresentation,
207-
data: *mut c_void)
208-
-> _Unwind_VRS_Result;
209-
210-
fn _Unwind_VRS_Set(ctx: *mut _Unwind_Context,
211-
regclass: _Unwind_VRS_RegClass,
212-
regno: _Unwind_Word,
213-
repr: _Unwind_VRS_DataRepresentation,
214-
data: *mut c_void)
215-
-> _Unwind_VRS_Result;
216-
}
168+
#[repr(C)]
169+
enum _Unwind_VRS_Result {
170+
_UVRSR_OK = 0,
171+
_UVRSR_NOT_IMPLEMENTED = 1,
172+
_UVRSR_FAILED = 2,
173+
}
174+
#[repr(C)]
175+
enum _Unwind_VRS_RegClass {
176+
_UVRSC_CORE = 0,
177+
_UVRSC_VFP = 1,
178+
_UVRSC_FPA = 2,
179+
_UVRSC_WMMXD = 3,
180+
_UVRSC_WMMXC = 4,
181+
}
182+
use _Unwind_VRS_RegClass::*;
183+
#[repr(C)]
184+
enum _Unwind_VRS_DataRepresentation {
185+
_UVRSD_UINT32 = 0,
186+
_UVRSD_VFPX = 1,
187+
_UVRSD_FPAX = 2,
188+
_UVRSD_UINT64 = 3,
189+
_UVRSD_FLOAT = 4,
190+
_UVRSD_DOUBLE = 5,
191+
}
192+
use _Unwind_VRS_DataRepresentation::*;
193+
194+
pub const UNWIND_POINTER_REG: c_int = 12;
195+
pub const UNWIND_SP_REG: c_int = 13;
196+
pub const UNWIND_IP_REG: c_int = 15;
197+
198+
#[cfg_attr(
199+
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
200+
link(name = "unwind", kind = "static", modifiers = "-bundle")
201+
)]
202+
unsafe extern "C" {
203+
fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
204+
regclass: _Unwind_VRS_RegClass,
205+
regno: _Unwind_Word,
206+
repr: _Unwind_VRS_DataRepresentation,
207+
data: *mut c_void)
208+
-> _Unwind_VRS_Result;
209+
210+
fn _Unwind_VRS_Set(ctx: *mut _Unwind_Context,
211+
regclass: _Unwind_VRS_RegClass,
212+
regno: _Unwind_Word,
213+
repr: _Unwind_VRS_DataRepresentation,
214+
data: *mut c_void)
215+
-> _Unwind_VRS_Result;
216+
}
217217

218-
// On Android or ARM/Linux, these are implemented as macros:
218+
// On Android or ARM/Linux, these are implemented as macros:
219219

220-
pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word {
221-
let mut val: _Unwind_Word = core::ptr::null();
222-
unsafe { _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32,
223-
(&raw mut val) as *mut c_void); }
224-
val
225-
}
220+
pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word {
221+
let mut val: _Unwind_Word = core::ptr::null();
222+
unsafe { _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32,
223+
(&raw mut val) as *mut c_void); }
224+
val
225+
}
226226

227-
pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) {
228-
let mut value = value;
229-
unsafe { _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32,
230-
(&raw mut value) as *mut c_void); }
231-
}
227+
pub unsafe fn _Unwind_SetGR(
228+
ctx: *mut _Unwind_Context,
229+
reg_index: c_int,
230+
value: _Unwind_Word
231+
) {
232+
let mut value = value;
233+
unsafe { _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32,
234+
(&raw mut value) as *mut c_void); }
235+
}
232236

233-
pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context)
234-
-> _Unwind_Word {
235-
let val = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG) };
236-
val.map_addr(|v| v & !1)
237-
}
237+
pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context)
238+
-> _Unwind_Word {
239+
let val = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG) };
240+
val.map_addr(|v| v & !1)
241+
}
238242

239-
pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context,
240-
value: _Unwind_Word) {
241-
// Propagate thumb bit to instruction pointer
242-
let thumb_state = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1 };
243-
let value = value.map_addr(|v| v | thumb_state);
244-
unsafe { _Unwind_SetGR(ctx, UNWIND_IP_REG, value); }
245-
}
243+
pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context,
244+
value: _Unwind_Word) {
245+
// Propagate thumb bit to instruction pointer
246+
let thumb_state = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1 };
247+
let value = value.map_addr(|v| v | thumb_state);
248+
unsafe { _Unwind_SetGR(ctx, UNWIND_IP_REG, value); }
249+
}
246250

247-
pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context,
248-
ip_before_insn: *mut c_int)
249-
-> _Unwind_Word {
250-
unsafe {
251-
*ip_before_insn = 0;
252-
_Unwind_GetIP(ctx)
251+
pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context,
252+
ip_before_insn: *mut c_int)
253+
-> _Unwind_Word {
254+
unsafe {
255+
*ip_before_insn = 0;
256+
_Unwind_GetIP(ctx)
257+
}
253258
}
254-
}
255259

256-
// This function also doesn't exist on Android or ARM/Linux, so make it a no-op
257-
pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void {
258-
pc
260+
// This function also doesn't exist on Android or ARM/Linux, so make it a no-op
261+
pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void {
262+
pc
263+
}
259264
}
260265
}
261-
} // cfg_select!
262266

263267
cfg_select! {
264-
all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm") => {
265-
// 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and
266-
// does not provide _Unwind_Backtrace()
267-
unsafe extern "C-unwind" {
268-
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
269-
}
268+
all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm") => {
269+
// 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and
270+
// does not provide _Unwind_Backtrace()
271+
unsafe extern "C-unwind" {
272+
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
273+
}
270274

271-
pub use _Unwind_SjLj_RaiseException as _Unwind_RaiseException;
272-
}
273-
_ => {
274-
#[cfg_attr(
275-
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
276-
link(name = "unwind", kind = "static", modifiers = "-bundle")
277-
)]
278-
unsafe extern "C-unwind" {
279-
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
275+
pub use _Unwind_SjLj_RaiseException as _Unwind_RaiseException;
280276
}
281-
#[cfg_attr(
282-
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
283-
link(name = "unwind", kind = "static", modifiers = "-bundle")
284-
)]
285-
unsafe extern "C" {
286-
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
287-
trace_argument: *mut c_void)
288-
-> _Unwind_Reason_Code;
277+
_ => {
278+
#[cfg_attr(
279+
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
280+
link(name = "unwind", kind = "static", modifiers = "-bundle")
281+
)]
282+
unsafe extern "C-unwind" {
283+
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
284+
}
285+
#[cfg_attr(
286+
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
287+
link(name = "unwind", kind = "static", modifiers = "-bundle")
288+
)]
289+
unsafe extern "C" {
290+
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
291+
trace_argument: *mut c_void)
292+
-> _Unwind_Reason_Code;
293+
}
289294
}
290295
}
291-
} // cfg_select!
292296

293297
cfg_select! {
294-
any(
295-
all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), target_env = "gnu"),
296-
target_os = "cygwin",
297-
) => {
298-
// We declare these as opaque types. This is fine since you just need to
299-
// pass them to _GCC_specific_handler and forget about them.
300-
pub enum EXCEPTION_RECORD {}
301-
pub type LPVOID = *mut c_void;
302-
pub enum CONTEXT {}
303-
pub enum DISPATCHER_CONTEXT {}
304-
pub type EXCEPTION_DISPOSITION = c_int;
305-
type PersonalityFn = unsafe extern "C" fn(version: c_int,
306-
actions: _Unwind_Action,
307-
exception_class: _Unwind_Exception_Class,
308-
exception_object: *mut _Unwind_Exception,
309-
context: *mut _Unwind_Context)
310-
-> _Unwind_Reason_Code;
311-
312-
unsafe extern "C" {
313-
pub fn _GCC_specific_handler(exceptionRecord: *mut EXCEPTION_RECORD,
314-
establisherFrame: LPVOID,
315-
contextRecord: *mut CONTEXT,
316-
dispatcherContext: *mut DISPATCHER_CONTEXT,
317-
personality: PersonalityFn)
318-
-> EXCEPTION_DISPOSITION;
298+
any(
299+
all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), target_env = "gnu"),
300+
target_os = "cygwin",
301+
) => {
302+
// We declare these as opaque types. This is fine since you just need to
303+
// pass them to _GCC_specific_handler and forget about them.
304+
pub enum EXCEPTION_RECORD {}
305+
pub type LPVOID = *mut c_void;
306+
pub enum CONTEXT {}
307+
pub enum DISPATCHER_CONTEXT {}
308+
pub type EXCEPTION_DISPOSITION = c_int;
309+
type PersonalityFn = unsafe extern "C" fn(version: c_int,
310+
actions: _Unwind_Action,
311+
exception_class: _Unwind_Exception_Class,
312+
exception_object: *mut _Unwind_Exception,
313+
context: *mut _Unwind_Context)
314+
-> _Unwind_Reason_Code;
315+
316+
unsafe extern "C" {
317+
pub fn _GCC_specific_handler(exceptionRecord: *mut EXCEPTION_RECORD,
318+
establisherFrame: LPVOID,
319+
contextRecord: *mut CONTEXT,
320+
dispatcherContext: *mut DISPATCHER_CONTEXT,
321+
personality: PersonalityFn)
322+
-> EXCEPTION_DISPOSITION;
323+
}
319324
}
325+
_ => {}
320326
}
321-
_ => {}
322-
} // cfg_select!

0 commit comments

Comments
 (0)