Skip to content

Commit 642956d

Browse files
authored
Merge pull request #402 from Freax13/enhancement/type-layout
set repr to transparent for various types
2 parents 0e2193f + 94677aa commit 642956d

File tree

6 files changed

+8
-1
lines changed

6 files changed

+8
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rust-version = "1.57" # Needed to support panic! in const fns
2121

2222
[dependencies]
2323
bit_field = "0.10.1"
24-
bitflags = "1.0.4"
24+
bitflags = "1.3.2"
2525
volatile = "0.4.4"
2626
rustversion = "1.0.5"
2727

src/registers/control.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct Cr0;
99

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

7980
bitflags! {
8081
/// Configuration flags of the [`Cr4`] register.
82+
#[repr(transparent)]
8183
pub struct Cr4Flags: u64 {
8284
/// Enables hardware-supported performance enhancements for software running in
8385
/// virtual-8086 mode.

src/registers/debug.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub struct Dr6;
109109

110110
bitflags! {
111111
/// Debug condition flags of the [`Dr6`] register.
112+
#[repr(transparent)]
112113
pub struct Dr6Flags: u64 {
113114
/// Breakpoint condition 0 was detected.
114115
const TRAP0 = 1;

src/registers/model_specific.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl SCet {
110110

111111
bitflags! {
112112
/// Flags of the Extended Feature Enable Register.
113+
#[repr(transparent)]
113114
pub struct EferFlags: u64 {
114115
/// Enables the `syscall` and `sysret` instructions.
115116
const SYSTEM_CALL_EXTENSIONS = 1;
@@ -133,6 +134,7 @@ bitflags! {
133134
bitflags! {
134135
/// Flags stored in IA32_U_CET and IA32_S_CET (Table-2-2 in Intel SDM Volume
135136
/// 4). The Intel SDM-equivalent names are described in parentheses.
137+
#[repr(transparent)]
136138
pub struct CetFlags: u64 {
137139
/// Enable shadow stack (SH_STK_EN)
138140
const SS_ENABLE = 1 << 0;

src/registers/rflags.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use bitflags::bitflags;
77

88
bitflags! {
99
/// The RFLAGS register.
10+
#[repr(transparent)]
1011
pub struct RFlags: u64 {
1112
/// Processor feature identification flag.
1213
///

src/registers/xcontrol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ bitflags! {
1010
///
1111
/// For MPX, [`BNDREG`](XCr0Flags::BNDREG) and [`BNDCSR`](XCr0Flags::BNDCSR) must be set/unset simultaneously.
1212
/// For AVX-512, [`OPMASK`](XCr0Flags::OPMASK), [`ZMM_HI256`](XCr0Flags::ZMM_HI256), and [`HI16_ZMM`](XCr0Flags::HI16_ZMM) must be set/unset simultaneously.
13+
#[repr(transparent)]
1314
pub struct XCr0Flags: u64 {
1415
/// Enables using the x87 FPU state
1516
/// with `XSAVE`/`XRSTOR`.

0 commit comments

Comments
 (0)