Skip to content

Commit b6d9311

Browse files
committed
Apply #[inline] attribute to bitbanding functions.
The generated code for the functions is usually only 1-2 instruction(s), calling such a function causes more overhead than inlining it. Most example binaries shrink up to 1kB with this hint. Signed-off-by: Daniel Egger <daniel@eggers-club.de>
1 parent 12b5bc1 commit b6d9311

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111

12+
- apply #[inline] attribute to bitbanding functions [#517]
1213
- update `stm32f4` to 0.15.1 [#481]
1314
- use `stm32_i2s_v12x` version 0.3, reexport it, and implements requirement for it [#490]
1415
- i2s module don't reuse marker from spi module and define its own [#490]
@@ -41,6 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4142
[#510]: https://github.com/stm32-rs/stm32f4xx-hal/pull/510
4243
[#514]: https://github.com/stm32-rs/stm32f4xx-hal/pull/514
4344
[#515]: https://github.com/stm32-rs/stm32f4xx-hal/pull/515
45+
[#517]: https://github.com/stm32-rs/stm32f4xx-hal/pull/517
4446

4547
## [v0.13.2] - 2022-05-16
4648

src/bb.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const PERI_BIT_BAND_BASE: usize = 0x4200_0000;
1818
/// # Safety
1919
///
2020
/// Some registers have reserved bits which should not be modified.
21+
#[inline]
2122
pub unsafe fn clear<T>(register: *const T, bit: u8) {
2223
write(register, bit, false);
2324
}
@@ -27,6 +28,7 @@ pub unsafe fn clear<T>(register: *const T, bit: u8) {
2728
/// # Safety
2829
///
2930
/// Some registers have reserved bits which should not be modified.
31+
#[inline]
3032
pub unsafe fn set<T>(register: *const T, bit: u8) {
3133
write(register, bit, true);
3234
}
@@ -36,6 +38,7 @@ pub unsafe fn set<T>(register: *const T, bit: u8) {
3638
/// # Safety
3739
///
3840
/// Some registers have reserved bits which should not be modified.
41+
#[inline]
3942
pub unsafe fn write<T>(register: *const T, bit: u8, set: bool) {
4043
let addr = register as usize;
4144

0 commit comments

Comments
 (0)