diff options
author | 2019-07-27 00:05:50 +0300 | |
---|---|---|
committer | 2019-07-27 00:16:43 +0300 | |
commit | 3c33d6c29bb546d8774d03825c10a28038c7f7e4 (patch) | |
tree | 90b095f86f5d8e9d88683d81f08eaaa719c7b605 /src/bits64/rflags.rs | |
parent | c5af691304d11b6b1a3df5dae6c546bd2a7fac4a (diff) | |
download | rust-x86-3c33d6c29bb546d8774d03825c10a28038c7f7e4.tar.gz rust-x86-3c33d6c29bb546d8774d03825c10a28038c7f7e4.tar.zst rust-x86-3c33d6c29bb546d8774d03825c10a28038c7f7e4.zip |
Always inline functions that operate on FLAGS register
Non-inlined functions have a function prologue[1] that contain instructions
which can mess with the FLAGS register before we have a chance to read it.
[1]: https://en.wikipedia.org/wiki/Function_prologue
Diffstat (limited to 'src/bits64/rflags.rs')
-rw-r--r-- | src/bits64/rflags.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/bits64/rflags.rs b/src/bits64/rflags.rs index 5f6fa11..970e19a 100644 --- a/src/bits64/rflags.rs +++ b/src/bits64/rflags.rs @@ -76,6 +76,7 @@ impl RFlags { } #[cfg(target_arch = "x86_64")] +#[inline(always)] pub unsafe fn read() -> RFlags { let r: u64; asm!("pushfq; popq $0" : "=r"(r) :: "memory"); @@ -83,6 +84,7 @@ pub unsafe fn read() -> RFlags { } #[cfg(target_arch = "x86_64")] +#[inline(always)] pub unsafe fn set(val: RFlags) { asm!("pushq $0; popfq" :: "r"(val.bits()) : "memory" "flags"); } |