Commit c64ef8a
committed
Prevent access to per-core variables without proper macro
Without this patch, it's possible to declare a per-core variable
like so:
declare_per_core! {
static mut TIMER_WHEEL: Option<TimerWheel> = None;
}
Then access the variable like:
unsafe {
TIMER_WHEEL = Some(value);
}
But this will always mutate the value on the BSP core (and is not
thread-safe). This patch generates a new symbol for the actual
static variable, which effectively requires the usage of the
'get_per_core' or 'get_per_core_mut' and prevents this category
of error.1 parent 06535b8 commit c64ef8a
3 files changed
+23
-6
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| |||
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
| |||
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
150 | | - | |
151 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
156 | | - | |
157 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
158 | 167 | | |
159 | 168 | | |
160 | 169 | | |
| |||
0 commit comments