Skip to content

Commit

Permalink
riscv: re-use mcountinhibit try_* functions
Browse files Browse the repository at this point in the history
Re-uses the `try_*` functions in their panicking equivalents for a
slight code-size reduction.
  • Loading branch information
rmsyn committed Oct 24, 2024
1 parent 63b748a commit bf766e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Use CSR helper macros to define `marchid` register
- Re-use `try_*` functions in `mcountinhibit`

## [v0.12.1] - 2024-10-20

Expand Down
6 changes: 2 additions & 4 deletions riscv/src/register/mcountinhibit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ set_clear_csr!(

#[inline]
pub unsafe fn set_hpm(index: usize) {
assert!((3..32).contains(&index));
_set(1 << index);
try_set_hpm(index).unwrap();
}

#[inline]
Expand All @@ -60,8 +59,7 @@ pub unsafe fn try_set_hpm(index: usize) -> Result<()> {

#[inline]
pub unsafe fn clear_hpm(index: usize) {
assert!((3..32).contains(&index));
_clear(1 << index);
try_clear_hpm(index).unwrap();
}

#[inline]
Expand Down

0 comments on commit bf766e1

Please sign in to comment.