Skip to content

Commit 073c8f0

Browse files
committed
Add #[inline] to some more functions.
Now the only public non-inline functions left are: - write_all - write_aligned - All (derived) Debug implementations (Checked using Clippy's missing_inline_in_public_items lint.)
1 parent 1608a66 commit 073c8f0

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

src/interrupt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub unsafe fn enable() {
5757
/// Execute closure `f` in an interrupt-free context.
5858
///
5959
/// This as also known as a "critical section".
60+
#[inline]
6061
pub fn free<F, R>(f: F) -> R
6162
where
6263
F: FnOnce(&CriticalSection) -> R,

src/peripheral/nvic.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl NVIC {
8383
/// `set_pending`.
8484
///
8585
/// This method is not available on ARMv6-M chips.
86+
#[inline]
8687
pub fn request<I>(&mut self, interrupt: I)
8788
where
8889
I: Nr,
@@ -96,6 +97,7 @@ impl NVIC {
9697

9798
/// Clears `interrupt`'s pending state
9899
#[deprecated(since = "0.5.8", note = "Use `NVIC::unpend`")]
100+
#[inline]
99101
pub fn clear_pending<I>(&mut self, interrupt: I)
100102
where
101103
I: Nr,
@@ -104,6 +106,7 @@ impl NVIC {
104106
}
105107

106108
/// Disables `interrupt`
109+
#[inline]
107110
pub fn mask<I>(interrupt: I)
108111
where
109112
I: Nr,
@@ -116,6 +119,7 @@ impl NVIC {
116119
/// Enables `interrupt`
117120
///
118121
/// This function is `unsafe` because it can break mask-based critical sections
122+
#[inline]
119123
pub unsafe fn unmask<I>(interrupt: I)
120124
where
121125
I: Nr,
@@ -127,6 +131,7 @@ impl NVIC {
127131

128132
/// Disables `interrupt`
129133
#[deprecated(since = "0.6.1", note = "Use `NVIC::mask`")]
134+
#[inline]
130135
pub fn disable<I>(&mut self, interrupt: I)
131136
where
132137
I: Nr,
@@ -137,6 +142,7 @@ impl NVIC {
137142
/// **WARNING** This method is a soundness hole in the API; it should actually be an `unsafe`
138143
/// function. Use `NVIC::unmask` which has the right unsafety.
139144
#[deprecated(since = "0.6.1", note = "Use `NVIC::unmask`")]
145+
#[inline]
140146
pub fn enable<I>(&mut self, interrupt: I)
141147
where
142148
I: Nr,
@@ -149,6 +155,7 @@ impl NVIC {
149155
/// *NOTE* NVIC encodes priority in the highest bits of a byte so values like `1` and `2` map
150156
/// to the same priority. Also for NVIC priorities, a lower value (e.g. `16`) has higher
151157
/// priority (urgency) than a larger value (e.g. `32`).
158+
#[inline]
152159
pub fn get_priority<I>(interrupt: I) -> u8
153160
where
154161
I: Nr,
@@ -171,6 +178,7 @@ impl NVIC {
171178

172179
/// Is `interrupt` active or pre-empted and stacked
173180
#[cfg(not(armv6m))]
181+
#[inline]
174182
pub fn is_active<I>(interrupt: I) -> bool
175183
where
176184
I: Nr,
@@ -183,6 +191,7 @@ impl NVIC {
183191
}
184192

185193
/// Checks if `interrupt` is enabled
194+
#[inline]
186195
pub fn is_enabled<I>(interrupt: I) -> bool
187196
where
188197
I: Nr,
@@ -195,6 +204,7 @@ impl NVIC {
195204
}
196205

197206
/// Checks if `interrupt` is pending
207+
#[inline]
198208
pub fn is_pending<I>(interrupt: I) -> bool
199209
where
200210
I: Nr,
@@ -207,6 +217,7 @@ impl NVIC {
207217
}
208218

209219
/// Forces `interrupt` into pending state
220+
#[inline]
210221
pub fn pend<I>(interrupt: I)
211222
where
212223
I: Nr,
@@ -219,6 +230,7 @@ impl NVIC {
219230

220231
/// Forces `interrupt` into pending state
221232
#[deprecated(since = "0.5.8", note = "Use `NVIC::pend`")]
233+
#[inline]
222234
pub fn set_pending<I>(&mut self, interrupt: I)
223235
where
224236
I: Nr,
@@ -238,6 +250,7 @@ impl NVIC {
238250
///
239251
/// Changing priority levels can break priority-based critical sections (see
240252
/// [`register::basepri`](../register/basepri/index.html)) and compromise memory safety.
253+
#[inline]
241254
pub unsafe fn set_priority<I>(&mut self, interrupt: I, prio: u8)
242255
where
243256
I: Nr,
@@ -260,6 +273,7 @@ impl NVIC {
260273
}
261274

262275
/// Clears `interrupt`'s pending state
276+
#[inline]
263277
pub fn unpend<I>(interrupt: I)
264278
where
265279
I: Nr,
@@ -271,6 +285,7 @@ impl NVIC {
271285
}
272286

273287
#[cfg(armv6m)]
288+
#[inline]
274289
fn ipr_index<I>(interrupt: &I) -> usize
275290
where
276291
I: Nr,
@@ -279,6 +294,7 @@ impl NVIC {
279294
}
280295

281296
#[cfg(armv6m)]
297+
#[inline]
282298
fn ipr_shift<I>(interrupt: &I) -> usize
283299
where
284300
I: Nr,

src/register/apsr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@ pub struct Apsr {
88

99
impl Apsr {
1010
/// Returns the contents of the register as raw bits
11+
#[inline]
1112
pub fn bits(self) -> u32 {
1213
self.bits
1314
}
1415

1516
/// DSP overflow and saturation flag
17+
#[inline]
1618
pub fn q(self) -> bool {
1719
self.bits & (1 << 27) == (1 << 27)
1820
}
1921

2022
/// Overflow flag
23+
#[inline]
2124
pub fn v(self) -> bool {
2225
self.bits & (1 << 28) == (1 << 28)
2326
}
2427

2528
/// Carry or borrow flag
29+
#[inline]
2630
pub fn c(self) -> bool {
2731
self.bits & (1 << 29) == (1 << 29)
2832
}
2933

3034
/// Zero flag
35+
#[inline]
3136
pub fn z(self) -> bool {
3237
self.bits & (1 << 30) == (1 << 30)
3338
}
3439

3540
/// Negative flag
41+
#[inline]
3642
pub fn n(self) -> bool {
3743
self.bits & (1 << 31) == (1 << 31)
3844
}

src/register/faultmask.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ pub enum Faultmask {
1111

1212
impl Faultmask {
1313
/// All exceptions are active
14+
#[inline]
1415
pub fn is_active(self) -> bool {
1516
self == Faultmask::Active
1617
}
1718

1819
/// All exceptions, except for NMI, are inactive
20+
#[inline]
1921
pub fn is_inactive(self) -> bool {
2022
self == Faultmask::Inactive
2123
}

src/register/primask.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ pub enum Primask {
1111

1212
impl Primask {
1313
/// All exceptions with configurable priority are active
14+
#[inline]
1415
pub fn is_active(self) -> bool {
1516
self == Primask::Active
1617
}
1718

1819
/// All exceptions with configurable priority are inactive
20+
#[inline]
1921
pub fn is_inactive(self) -> bool {
2022
self == Primask::Inactive
2123
}

0 commit comments

Comments
 (0)