Skip to content

Commit

Permalink
feat(xcontrol): add XCr0::update()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Dec 24, 2024
1 parent 61cd811 commit cf1d872
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/registers/xcontrol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,26 @@ mod x86_64 {
);
}
}

/// Updates XCR0 flags.
///
/// Preserves the value of reserved fields.
/// Panics if invalid combinations of [`XCr0Flags`] are set.
///
/// ## Safety
///
/// This function is unsafe because it's possible to
/// enable features that are not supported by the architecture.
#[inline]
pub unsafe fn update<F>(f: F)
where
F: FnOnce(&mut XCr0Flags),
{
let mut flags = Self::read();
f(&mut flags);
unsafe {
Self::write(flags);
}
}
}
}

0 comments on commit cf1d872

Please sign in to comment.