Skip to content

Commit

Permalink
Merge pull request #402 from Freax13/enhancement/type-layout
Browse files Browse the repository at this point in the history
set repr to transparent for various types
  • Loading branch information
Freax13 committed Jan 25, 2023
2 parents 0e2193f + 94677aa commit 642956d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rust-version = "1.57" # Needed to support panic! in const fns

[dependencies]
bit_field = "0.10.1"
bitflags = "1.0.4"
bitflags = "1.3.2"
volatile = "0.4.4"
rustversion = "1.0.5"

Expand Down
2 changes: 2 additions & 0 deletions src/registers/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct Cr0;

bitflags! {
/// Configuration flags of the [`Cr0`] register.
#[repr(transparent)]
pub struct Cr0Flags: u64 {
/// Enables protected mode.
const PROTECTED_MODE_ENABLE = 1;
Expand Down Expand Up @@ -78,6 +79,7 @@ pub struct Cr4;

bitflags! {
/// Configuration flags of the [`Cr4`] register.
#[repr(transparent)]
pub struct Cr4Flags: u64 {
/// Enables hardware-supported performance enhancements for software running in
/// virtual-8086 mode.
Expand Down
1 change: 1 addition & 0 deletions src/registers/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub struct Dr6;

bitflags! {
/// Debug condition flags of the [`Dr6`] register.
#[repr(transparent)]
pub struct Dr6Flags: u64 {
/// Breakpoint condition 0 was detected.
const TRAP0 = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/registers/model_specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl SCet {

bitflags! {
/// Flags of the Extended Feature Enable Register.
#[repr(transparent)]
pub struct EferFlags: u64 {
/// Enables the `syscall` and `sysret` instructions.
const SYSTEM_CALL_EXTENSIONS = 1;
Expand All @@ -133,6 +134,7 @@ bitflags! {
bitflags! {
/// Flags stored in IA32_U_CET and IA32_S_CET (Table-2-2 in Intel SDM Volume
/// 4). The Intel SDM-equivalent names are described in parentheses.
#[repr(transparent)]
pub struct CetFlags: u64 {
/// Enable shadow stack (SH_STK_EN)
const SS_ENABLE = 1 << 0;
Expand Down
1 change: 1 addition & 0 deletions src/registers/rflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bitflags::bitflags;

bitflags! {
/// The RFLAGS register.
#[repr(transparent)]
pub struct RFlags: u64 {
/// Processor feature identification flag.
///
Expand Down
1 change: 1 addition & 0 deletions src/registers/xcontrol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bitflags! {
///
/// For MPX, [`BNDREG`](XCr0Flags::BNDREG) and [`BNDCSR`](XCr0Flags::BNDCSR) must be set/unset simultaneously.
/// For AVX-512, [`OPMASK`](XCr0Flags::OPMASK), [`ZMM_HI256`](XCr0Flags::ZMM_HI256), and [`HI16_ZMM`](XCr0Flags::HI16_ZMM) must be set/unset simultaneously.
#[repr(transparent)]
pub struct XCr0Flags: u64 {
/// Enables using the x87 FPU state
/// with `XSAVE`/`XRSTOR`.
Expand Down

0 comments on commit 642956d

Please sign in to comment.