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 } ;
4
2
5
- use crate :: interrupt;
6
- use crate :: register:: primask;
3
+ use crate :: interrupt;
4
+ use crate :: register:: primask;
7
5
8
- struct SingleCoreCriticalSection ;
9
- set_impl ! ( SingleCoreCriticalSection ) ;
6
+ struct SingleCoreCriticalSection ;
7
+ set_impl ! ( SingleCoreCriticalSection ) ;
10
8
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
+ }
17
15
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 ( )
23
20
}
24
21
}
25
22
}
26
-
27
- pub use critical_section:: with;
Original file line number Diff line number Diff line change @@ -49,10 +49,6 @@ mod macros;
49
49
pub mod asm;
50
50
#[ cfg( armv8m) ]
51
51
pub 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;
56
52
pub mod delay;
57
53
pub mod interrupt;
58
54
#[ cfg( all( not( armv6m) , not( armv8m_base) ) ) ]
@@ -61,3 +57,13 @@ pub mod peripheral;
61
57
pub mod register;
62
58
63
59
pub 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 {
65
65
#[ macro_export]
66
66
macro_rules! singleton {
67
67
( $name: ident: $ty: ty = $expr: expr) => {
68
- $crate:: critical_section:: with( |_| {
68
+ $crate:: _export :: critical_section:: with( |_| {
69
69
// this is a tuple of a MaybeUninit and a bool because using an Option here is
70
70
// problematic: Due to niche-optimization, an Option could end up producing a non-zero
71
71
// initializer value which would move the entire static from `.bss` into `.data`...
You can’t perform that action at this time.
0 commit comments