]> git.proxmox.com Git - rustc.git/blob - library/stdarch/crates/core_arch/src/x86/eflags.rs
New upstream version 1.54.0+dfsg1
[rustc.git] / library / stdarch / crates / core_arch / src / x86 / eflags.rs
1 //! `i386` intrinsics
2
3 /// Reads EFLAGS.
4 ///
5 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=__readeflags)
6 #[cfg(target_arch = "x86")]
7 #[inline(always)]
8 #[stable(feature = "simd_x86", since = "1.27.0")]
9 #[rustc_deprecated(
10 since = "1.29.0",
11 reason = "See issue #51810 - use inline assembly instead"
12 )]
13 #[doc(hidden)]
14 pub unsafe fn __readeflags() -> u32 {
15 let eflags: u32;
16 asm!("pushfd", "pop {}", out(reg) eflags, options(nomem, att_syntax));
17 eflags
18 }
19
20 /// Reads EFLAGS.
21 ///
22 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=__readeflags)
23 #[cfg(target_arch = "x86_64")]
24 #[inline(always)]
25 #[stable(feature = "simd_x86", since = "1.27.0")]
26 #[rustc_deprecated(
27 since = "1.29.0",
28 reason = "See issue #51810 - use inline assembly instead"
29 )]
30 #[doc(hidden)]
31 pub unsafe fn __readeflags() -> u64 {
32 let eflags: u64;
33 asm!("pushfq", "pop {}", out(reg) eflags, options(nomem, att_syntax));
34 eflags
35 }
36
37 /// Write EFLAGS.
38 ///
39 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=__writeeflags)
40 #[cfg(target_arch = "x86")]
41 #[inline(always)]
42 #[stable(feature = "simd_x86", since = "1.27.0")]
43 #[rustc_deprecated(
44 since = "1.29.0",
45 reason = "See issue #51810 - use inline assembly instead"
46 )]
47 #[doc(hidden)]
48 pub unsafe fn __writeeflags(eflags: u32) {
49 asm!("push {}", "popfd", in(reg) eflags, options(nomem, att_syntax));
50 }
51
52 /// Write EFLAGS.
53 ///
54 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=__writeeflags)
55 #[cfg(target_arch = "x86_64")]
56 #[inline(always)]
57 #[stable(feature = "simd_x86", since = "1.27.0")]
58 #[rustc_deprecated(
59 since = "1.29.0",
60 reason = "See issue #51810 - use inline assembly instead"
61 )]
62 #[doc(hidden)]
63 pub unsafe fn __writeeflags(eflags: u64) {
64 asm!("push {}", "popfq", in(reg) eflags, options(nomem, att_syntax));
65 }
66
67 #[cfg(test)]
68 mod tests {
69 use crate::core_arch::x86::*;
70
71 #[test]
72 #[allow(deprecated)]
73 fn test_eflags() {
74 unsafe {
75 // reads eflags, writes them back, reads them again,
76 // and compare for equality:
77 let v = __readeflags();
78 __writeeflags(v);
79 let u = __readeflags();
80 assert_eq!(v, u);
81 }
82 }
83 }