Skip to content

Commit

Permalink
Merge #334
Browse files Browse the repository at this point in the history
334: Remove an extra function call in `primask::read` r=jonas-schievink a=yvt

There doesn't seem to be any reason why the call to `__primask_r` should be wrapped by another function call. `read_raw` (the function being removed by this PR) is not `#[inline]`, so it did hurt performance when compiled without LTO.

Compare with `faultmask::read`:
https://github.com/rust-embedded/cortex-m/blob/7481f09d67aee7081d71cf6e042f2984c12a830f/src/register/faultmask.rs#L26-L35

Co-authored-by: yvt <i@yvt.jp>
  • Loading branch information
bors[bot] and yvt committed Feb 19, 2021
2 parents 7481f09 + e802d0e commit e8179ec
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/register/primask.rs
Expand Up @@ -26,11 +26,7 @@ impl Primask {
/// Reads the CPU register
#[inline]
pub fn read() -> Primask {
fn read_raw() -> u32 {
call_asm!(__primask_r() -> u32)
}

let r = read_raw();
let r: u32 = call_asm!(__primask_r() -> u32);
if r & (1 << 0) == (1 << 0) {
Primask::Inactive
} else {
Expand Down

0 comments on commit e8179ec

Please sign in to comment.