File tree 3 files changed +5
-23
lines changed
3 files changed +5
-23
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,7 @@ version = "0.1.2"
23
23
default-features = false
24
24
version = " 0.1.2"
25
25
26
- [dependencies .untagged-option ]
27
- optional = true
28
- version = " 0.1.1"
29
-
30
26
[features ]
31
27
cm7-r0p1 = []
32
- default = [" inline-asm" , " singleton " ]
28
+ default = [" inline-asm" ]
33
29
inline-asm = []
34
- singleton = [" untagged-option" ]
Original file line number Diff line number Diff line change 14
14
15
15
extern crate aligned;
16
16
extern crate bare_metal;
17
- #[ cfg( feature = "singleton" ) ]
18
- extern crate untagged_option;
19
17
extern crate volatile_register;
20
18
21
19
#[ macro_use]
Original file line number Diff line number Diff line change @@ -50,32 +50,23 @@ macro_rules! iprintln {
50
50
/// }
51
51
/// ```
52
52
#[ macro_export]
53
- // TODO(stable) needs stable const `mem::uninitialized` OR stable const `MaybeUninit::new()` (RFC
54
- // 1892)
55
- #[ cfg( feature = "singleton" ) ]
56
53
macro_rules! singleton {
57
54
( : $ty: ty = $expr: expr) => {
58
55
$crate:: interrupt:: free( |_| {
59
- static mut USED : bool = false ;
60
- static mut VAR : $crate:: UntaggedOption <$ty> = $crate:: UntaggedOption { none: ( ) } ;
56
+ static mut VAR : Option <$ty> = None ;
61
57
62
58
#[ allow( unsafe_code) ]
63
- let used = unsafe { USED } ;
59
+ let used = unsafe { VAR . is_some ( ) } ;
64
60
if used {
65
61
None
66
62
} else {
67
- #[ allow( unsafe_code) ]
68
- unsafe { USED = true }
69
-
70
63
let expr = $expr;
71
64
72
65
#[ allow( unsafe_code) ]
73
- unsafe { VAR . some = expr }
66
+ unsafe { VAR = Some ( expr) }
74
67
75
68
#[ allow( unsafe_code) ]
76
- let var: & ' static mut _ = unsafe { & mut VAR . some } ;
77
-
78
- Some ( var)
69
+ unsafe { VAR . as_mut( ) }
79
70
}
80
71
} )
81
72
}
@@ -94,7 +85,6 @@ macro_rules! singleton {
94
85
/// }
95
86
/// ```
96
87
#[ allow( dead_code) ]
97
- #[ cfg( feature = "singleton" ) ]
98
88
const CFAIL : ( ) = ( ) ;
99
89
100
90
/// ```
@@ -110,5 +100,4 @@ const CFAIL: () = ();
110
100
/// }
111
101
/// ```
112
102
#[ allow( dead_code) ]
113
- #[ cfg( feature = "singleton" ) ]
114
103
const CPASS : ( ) = ( ) ;
You can’t perform that action at this time.
0 commit comments