Skip to content

Commit a9d701e

Browse files
author
Jorge Aparicio
committed
add a Local.borrow_mut method, default_handler now takes the context token by
value
1 parent f6615b0 commit a9d701e

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/ctxt.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ where
2525
}
2626

2727
/// Acquires a reference to the context local data
28-
pub fn borrow<'a>(&'static self, _ctxt: &'a Ctxt) -> &'a T {
28+
pub fn borrow<'ctxt>(&'static self, _ctxt: &'ctxt Ctxt) -> &'ctxt T {
2929
unsafe { &*self.data.get() }
3030
}
31+
32+
/// Acquires a mutable reference to the context local data
33+
pub fn borrow_mut<'ctxt>(
34+
&'static self,
35+
_ctxt: &'ctxt mut Ctxt,
36+
) -> &'ctxt mut T {
37+
unsafe { &mut *self.data.get() }
38+
}
3139
}
3240

3341
unsafe impl<T, Ctxt> Sync for Local<T, Ctxt>

src/exception.rs

Lines changed: 9 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: unsafe extern "C" fn(Nmi),
5858
/// All class of fault
59-
pub hard_fault: unsafe extern "C" fn(&HardFault),
59+
pub hard_fault: unsafe extern "C" fn(HardFault),
6060
/// Memory management
61-
pub mem_manage: unsafe extern "C" fn(&MemManage),
61+
pub mem_manage: unsafe extern "C" fn(MemManage),
6262
/// Pre-fetch fault, memory access fault
63-
pub bus_fault: unsafe extern "C" fn(&BusFault),
63+
pub bus_fault: unsafe extern "C" fn(BusFault),
6464
/// Undefined instruction or illegal state
65-
pub usage_fault: unsafe extern "C" fn(&UsageFault),
65+
pub usage_fault: unsafe 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: unsafe 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: unsafe extern "C" fn(Pendsv),
7474
/// System tick timer
75-
pub sys_tick: unsafe extern "C" fn(&SysTick),
75+
pub sys_tick: unsafe extern "C" fn(SysTick),
7676
}
7777

7878
/// Non-maskable interrupt
@@ -150,7 +150,7 @@ pub const DEFAULT_HANDLERS: Handlers = Handlers {
150150
// This needs asm!, #[naked] and unreachable() to avoid modifying the stack
151151
// pointer (MSP), that way it points to the stacked registers
152152
#[naked]
153-
pub unsafe extern "C" fn default_handler<T>(_token: &T) {
153+
pub unsafe extern "C" fn default_handler<T>(_token: T) {
154154
// This is the actual exception handler. `_sf` is a pointer to the previous
155155
// stack frame
156156
#[cfg(target_arch = "arm")]

0 commit comments

Comments
 (0)