Skip to content

Commit 6d4478d

Browse files
author
Jorge Aparicio
committed
remove unsafe from exception::default_handler
1 parent 23c2ee2 commit 6d4478d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/exception.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ impl Exception {
5454
#[repr(C)]
5555
pub struct Handlers {
5656
/// Non-maskable interrupt
57-
pub nmi: unsafe extern "C" fn(Nmi),
57+
pub nmi: extern "C" fn(Nmi),
5858
/// All class of fault
59-
pub hard_fault: unsafe extern "C" fn(HardFault),
59+
pub hard_fault: extern "C" fn(HardFault),
6060
/// Memory management
61-
pub mem_manage: unsafe extern "C" fn(MemManage),
61+
pub mem_manage: extern "C" fn(MemManage),
6262
/// Pre-fetch fault, memory access fault
63-
pub bus_fault: unsafe extern "C" fn(BusFault),
63+
pub bus_fault: extern "C" fn(BusFault),
6464
/// Undefined instruction or illegal state
65-
pub usage_fault: unsafe extern "C" fn(UsageFault),
65+
pub usage_fault: extern "C" fn(UsageFault),
6666
/// Reserved spots in the vector table
6767
pub _reserved0: [Reserved; 4],
6868
/// System service call via SWI instruction
69-
pub svcall: unsafe extern "C" fn(Svcall),
69+
pub svcall: extern "C" fn(Svcall),
7070
/// Reserved spots in the vector table
7171
pub _reserved1: [Reserved; 2],
7272
/// Pendable request for system service
73-
pub pendsv: unsafe extern "C" fn(Pendsv),
73+
pub pendsv: extern "C" fn(Pendsv),
7474
/// System tick timer
75-
pub sys_tick: unsafe extern "C" fn(SysTick),
75+
pub sys_tick: extern "C" fn(SysTick),
7676
}
7777

7878
/// Non-maskable interrupt
@@ -123,6 +123,8 @@ unsafe impl Context for MemManage {}
123123

124124
unsafe impl Context for BusFault {}
125125

126+
unsafe impl Context for UsageFault {}
127+
126128
unsafe impl Context for Svcall {}
127129

128130
unsafe impl Context for Pendsv {}
@@ -150,7 +152,9 @@ pub const DEFAULT_HANDLERS: Handlers = Handlers {
150152
// This needs asm!, #[naked] and unreachable() to avoid modifying the stack
151153
// pointer (MSP), that way it points to the stacked registers
152154
#[naked]
153-
pub unsafe extern "C" fn default_handler<T>(_token: T) {
155+
pub extern "C" fn default_handler<T>(_token: T)
156+
where T: Context
157+
{
154158
// This is the actual exception handler. `_sf` is a pointer to the previous
155159
// stack frame
156160
#[cfg(target_arch = "arm")]

0 commit comments

Comments
 (0)