File tree Expand file tree Collapse file tree 3 files changed +26
-25
lines changed Expand file tree Collapse file tree 3 files changed +26
-25
lines changed Original file line number Diff line number Diff line change 1- #[ cfg( all( cortex_m, feature = "critical-section-single-core" ) ) ]
2- mod single_core_critical_section {
3- use critical_section:: { set_impl, Impl , RawRestoreState } ;
1+ use critical_section:: { set_impl, Impl , RawRestoreState } ;
42
5- use crate :: interrupt;
6- use crate :: register:: primask;
3+ use crate :: interrupt;
4+ use crate :: register:: primask;
75
8- struct SingleCoreCriticalSection ;
9- set_impl ! ( SingleCoreCriticalSection ) ;
6+ struct SingleCoreCriticalSection ;
7+ set_impl ! ( SingleCoreCriticalSection ) ;
108
11- unsafe impl Impl for SingleCoreCriticalSection {
12- unsafe fn acquire ( ) -> RawRestoreState {
13- let was_active = primask:: read ( ) . is_active ( ) ;
14- interrupt:: disable ( ) ;
15- was_active
16- }
9+ unsafe impl Impl for SingleCoreCriticalSection {
10+ unsafe fn acquire ( ) -> RawRestoreState {
11+ let was_active = primask:: read ( ) . is_active ( ) ;
12+ interrupt:: disable ( ) ;
13+ was_active
14+ }
1715
18- unsafe fn release ( was_active : RawRestoreState ) {
19- // Only re-enable interrupts if they were enabled before the critical section.
20- if was_active {
21- interrupt:: enable ( )
22- }
16+ unsafe fn release ( was_active : RawRestoreState ) {
17+ // Only re-enable interrupts if they were enabled before the critical section.
18+ if was_active {
19+ interrupt:: enable ( )
2320 }
2421 }
2522}
26-
27- pub use critical_section:: with;
Original file line number Diff line number Diff line change @@ -49,10 +49,6 @@ mod macros;
4949pub mod asm;
5050#[ cfg( armv8m) ]
5151pub mod cmse;
52- // This is only public so the `singleton` macro does not require depending on
53- // the `critical-section` crate separately.
54- #[ doc( hidden) ]
55- pub mod critical_section;
5652pub mod delay;
5753pub mod interrupt;
5854#[ cfg( all( not( armv6m) , not( armv8m_base) ) ) ]
@@ -61,3 +57,13 @@ pub mod peripheral;
6157pub mod register;
6258
6359pub use crate :: peripheral:: Peripherals ;
60+
61+ #[ cfg( all( cortex_m, feature = "critical-section-single-core" ) ) ]
62+ mod critical_section;
63+
64+ /// Used to reexport items for use in macros. Do not use directly.
65+ /// Not covered by semver guarantees.
66+ #[ doc( hidden) ]
67+ pub mod _export {
68+ pub use critical_section;
69+ }
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ macro_rules! iprintln {
6565#[ macro_export]
6666macro_rules! singleton {
6767 ( $name: ident: $ty: ty = $expr: expr) => {
68- $crate:: critical_section:: with( |_| {
68+ $crate:: _export :: critical_section:: with( |_| {
6969 // this is a tuple of a MaybeUninit and a bool because using an Option here is
7070 // problematic: Due to niche-optimization, an Option could end up producing a non-zero
7171 // initializer value which would move the entire static from `.bss` into `.data`...
You can’t perform that action at this time.
0 commit comments