summaryrefslogtreecommitdiff
path: root/src/windows
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2021-09-18 22:19:11 +0100
committerDavid Carlier <devnexen@gmail.com>2021-09-18 22:37:22 +0100
commit6d09f2c9016c27f8207c6fc386c703dfaa9ed639 (patch)
tree77dd9d7be10d07c7944e8837bc7f47c2e5c41ba8 /src/windows
parent1ac780a77a92afb37975974f90e371a360c06626 (diff)
downloadrust-libc-6d09f2c9016c27f8207c6fc386c703dfaa9ed639.tar.gz
windows adding CONTEXT type for x86_64 arch.
Diffstat (limited to 'src/windows')
-rw-r--r--src/windows/msvc/mod.rs (renamed from src/windows/msvc.rs)9
-rw-r--r--src/windows/msvc/x86_64.rs140
2 files changed, 149 insertions, 0 deletions
diff --git a/src/windows/msvc.rs b/src/windows/msvc/mod.rs
index b4c98a8496..3d71dc627e 100644
--- a/src/windows/msvc.rs
+++ b/src/windows/msvc/mod.rs
@@ -11,3 +11,12 @@ extern "C" {
#[link_name = "_strnicmp"]
pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char, n: ::size_t) -> ::c_int;
}
+
+cfg_if! {
+ if #[cfg(target_arch = "x86_64")] {
+ mod x86_64;
+ pub use self::x86_64::*;
+ } else {
+ // Unknown target_arch
+ }
+}
diff --git a/src/windows/msvc/x86_64.rs b/src/windows/msvc/x86_64.rs
new file mode 100644
index 0000000000..249e590165
--- /dev/null
+++ b/src/windows/msvc/x86_64.rs
@@ -0,0 +1,140 @@
+pub type XMM_SAVE_AREA32 = XSAVE_FORMAT;
+
+s_no_extra_traits! {
+ #[repr(align(16))]
+ pub union __c_anonymous_CONTEXT_FP {
+ pub FltSave: ::XMM_SAVE_AREA32,
+ pub Xmm: __c_anonymous_CONTEXT_XMM,
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for __c_anonymous_CONTEXT_FP {
+ fn eq(&self, other: &__c_anonymous_CONTEXT_FP) -> bool {
+ unsafe {
+ self.FltSave == other.FltSave ||
+ self.Xmm == other.Xmm
+ }
+ }
+ }
+ impl Eq for __c_anonymous_CONTEXT_FP {}
+ impl ::fmt::Debug for __c_anonymous_CONTEXT_FP {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ unsafe {
+ f.debug_struct("__c_anonymous_CONTEXT_FP")
+ .field("FltSave", &self.FltSave)
+ .finish()
+ }
+ }
+ }
+ impl ::hash::Hash for __c_anonymous_CONTEXT_FP {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ unsafe {
+ self.FltSave.hash(state);
+ self.Xmm.hash(state);
+ }
+ }
+ }
+ }
+}
+
+s! {
+ #[repr(align(16))]
+ pub struct M128A {
+ pub Low: ::c_ulonglong,
+ pub High: ::c_longlong,
+ }
+
+ #[repr(align(16))]
+ pub struct XSAVE_FORMAT {
+ pub ControlWord: ::c_ushort,
+ pub StatusWord: ::c_ushort,
+ pub TagWord: ::c_uchar,
+ _Reserved1: ::c_uchar,
+ pub ErrorOpcode: ::c_ushort,
+ pub ErrorOffset: ::c_ulong,
+ pub ErrorSelector: ::c_ushort,
+ _Reserved2: ::c_ushort,
+ pub DataOffset: ::c_ulong,
+ pub DataSelector: ::c_ushort,
+ _Reserved3: ::c_ushort,
+ pub MxCsr: ::c_ulong,
+ pub MxCsr_Mask: ::c_ulong,
+ pub FloatRegisters: [M128A; 8],
+ pub XmmRegisters: [M128A; 16],
+ _Reserved4: [::c_uchar; 96],
+ }
+
+ #[repr(align(16))]
+ pub struct __c_anonymous_CONTEXT_XMM {
+ pub Header: [M128A; 2],
+ pub Legacy: [M128A; 8],
+ pub Xmm0: M128A,
+ pub Xmm1: M128A,
+ pub Xmm2: M128A,
+ pub Xmm3: M128A,
+ pub Xmm4: M128A,
+ pub Xmm5: M128A,
+ pub Xmm6: M128A,
+ pub Xmm7: M128A,
+ pub Xmm8: M128A,
+ pub Xmm9: M128A,
+ pub Xmm10: M128A,
+ pub Xmm11: M128A,
+ pub Xmm12: M128A,
+ pub Xmm13: M128A,
+ pub Xmm14: M128A,
+ pub Xmm15: M128A,
+ }
+
+ #[repr(align(16))]
+ pub struct CONTEXT {
+ pub P1Home: u64,
+ pub P2Home: u64,
+ pub P3Home: u64,
+ pub P4Home: u64,
+ pub P5Home: u64,
+ pub P6Home: u64,
+ pub ContextFlags: ::c_ulong,
+ pub MxCsr: ::c_ulong,
+ pub SegCs: ::c_ushort,
+ pub SegDs: ::c_ushort,
+ pub SegEs: ::c_ushort,
+ pub SegFs: ::c_ushort,
+ pub SegGs: ::c_ushort,
+ pub SegSs: ::c_ushort,
+ pub EFlags: ::c_ulong,
+ pub Dr0: u64,
+ pub Dr1: u64,
+ pub Dr2: u64,
+ pub Dr3: u64,
+ pub Dr6: u64,
+ pub Dr7: u64,
+ pub Rax: u64,
+ pub Rcx: u64,
+ pub Rdx: u64,
+ pub Rbx: u64,
+ pub Rsp: u64,
+ pub Rbp: u64,
+ pub Rsi: u64,
+ pub Rdi: u64,
+ pub R8: u64,
+ pub R9: u64,
+ pub R10: u64,
+ pub R11: u64,
+ pub R12: u64,
+ pub R13: u64,
+ pub R14: u64,
+ pub R15: u64,
+ pub Rip: u64,
+ pub Fp: __c_anonymous_CONTEXT_FP,
+ pub VectorRegister: [M128A; 26],
+ pub VectorControl: u64,
+ pub DebugControl: u64,
+ pub LastBranchToRip: u64,
+ pub LastBranchFromRip: u64,
+ pub LastExceptionToRip: u64,
+ pub LastExceptionFromRip: u64,
+ }
+}