diff options
author | 2017-03-07 22:56:06 -0500 | |
---|---|---|
committer | 2017-03-07 22:58:33 -0500 | |
commit | c3a35c1b6cea81aa71e8832bca79ccafa492be02 (patch) | |
tree | e868906d20c906d238be96cd5c07b07342f7a111 /src/interrupt.rs | |
parent | 9d3f3f323f3b7543d0b49e773aea2c68e535ec83 (diff) | |
download | cortex-m-c3a35c1b6cea81aa71e8832bca79ccafa492be02.tar.gz cortex-m-c3a35c1b6cea81aa71e8832bca79ccafa492be02.tar.zst cortex-m-c3a35c1b6cea81aa71e8832bca79ccafa492be02.zip |
revamp for memory safety
Diffstat (limited to 'src/interrupt.rs')
-rw-r--r-- | src/interrupt.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/interrupt.rs b/src/interrupt.rs index 2552892..95829ca 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -72,21 +72,22 @@ pub fn enable() { /// Critical section token /// /// Indicates that you are executing code within a critical section -pub struct CsToken { - _private: (), +pub struct CsCtxt { + _0: (), } /// Execute closure `f` in an interrupt-free context. +/// /// This as also known as a "critical section". pub fn free<F, R>(f: F) -> R - where F: FnOnce(&CsToken) -> R + where F: FnOnce(&CsCtxt) -> R { let primask = ::register::primask::read(); // disable interrupts disable(); - let r = f(&CsToken { _private: () }); + let r = f(&CsCtxt { _0: () }); // If the interrupts were active before our `disable` call, then re-enable // them. Otherwise, keep them disabled |