summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-06-23 15:34:37 +0900
committerGitHub <noreply@github.com>2020-06-23 15:34:37 +0900
commit95d8f481b595e0c952afbedd26bdd1b188629877 (patch)
treee55cab83abb3167c627c7639af68d7c7704b188b
parent7040aae669ec3551ed47fead4889eca26e565a00 (diff)
parent4a9413ba54de8fbb3e568f2da04442dfaa79b95e (diff)
downloadrust-libc-95d8f481b595e0c952afbedd26bdd1b188629877.tar.gz
Merge pull request #1791 from SWW13/freebsd-reg
FreeBSD: machine register structs
-rw-r--r--libc-test/build.rs1
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs170
2 files changed, 171 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index f9de7b313b..1d1f953080 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1644,6 +1644,7 @@ fn test_freebsd(target: &str) {
"libutil.h",
"limits.h",
"locale.h",
+ "machine/reg.h",
"mqueue.h",
"net/bpf.h",
"net/if.h",
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
index 0769a22f88..ff8f9a9d3e 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
@@ -4,6 +4,176 @@ pub type c_ulong = u64;
pub type time_t = i64;
pub type suseconds_t = i64;
+s! {
+ pub struct reg32 {
+ pub r_fs: u32,
+ pub r_es: u32,
+ pub r_ds: u32,
+ pub r_edi: u32,
+ pub r_esi: u32,
+ pub r_ebp: u32,
+ pub r_isp: u32,
+ pub r_ebx: u32,
+ pub r_edx: u32,
+ pub r_ecx: u32,
+ pub r_eax: u32,
+ pub r_trapno: u32,
+ pub r_err: u32,
+ pub r_eip: u32,
+ pub r_cs: u32,
+ pub r_eflags: u32,
+ pub r_esp: u32,
+ pub r_ss: u32,
+ pub r_gs: u32,
+ }
+
+ pub struct reg {
+ pub r_r15: i64,
+ pub r_r14: i64,
+ pub r_r13: i64,
+ pub r_r12: i64,
+ pub r_r11: i64,
+ pub r_r10: i64,
+ pub r_r9: i64,
+ pub r_r8: i64,
+ pub r_rdi: i64,
+ pub r_rsi: i64,
+ pub r_rbp: i64,
+ pub r_rbx: i64,
+ pub r_rdx: i64,
+ pub r_rcx: i64,
+ pub r_rax: i64,
+ pub r_trapno: u32,
+ pub r_fs: u16,
+ pub r_gs: u16,
+ pub r_err: u32,
+ pub r_es: u16,
+ pub r_ds: u16,
+ pub r_rip: i64,
+ pub r_cs: i64,
+ pub r_rflags: i64,
+ pub r_rsp: i64,
+ pub r_ss: i64,
+ }
+}
+
+s_no_extra_traits! {
+ pub struct fpreg32 {
+ pub fpr_env: [u32; 7],
+ pub fpr_acc: [[u8; 10]; 8],
+ pub fpr_ex_sw: u32,
+ pub fpr_pad: [u8; 64],
+ }
+
+ pub struct fpreg {
+ pub fpr_env: [u64; 4],
+ pub fpr_acc: [[u8; 16]; 8],
+ pub fpr_xacc: [[u8; 16]; 16],
+ pub fpr_spare: [u64; 12],
+ }
+
+ pub struct xmmreg {
+ pub xmm_env: [u32; 8],
+ pub xmm_acc: [[u8; 16]; 8],
+ pub xmm_reg: [[u8; 16]; 8],
+ pub xmm_pad: [u8; 224],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for fpreg32 {
+ fn eq(&self, other: &fpreg32) -> bool {
+ self.fpr_env == other.fpr_env &&
+ self.fpr_acc == other.fpr_acc &&
+ self.fpr_ex_sw == other.fpr_ex_sw &&
+ self.fpr_pad
+ .iter()
+ .zip(other.fpr_pad.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for fpreg32 {}
+ impl ::fmt::Debug for fpreg32 {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("fpreg32")
+ .field("fpr_env", &&self.fpr_env[..])
+ .field("fpr_acc", &self.fpr_acc)
+ .field("fpr_ex_sw", &self.fpr_ex_sw)
+ .field("fpr_pad", &&self.fpr_pad[..])
+ .finish()
+ }
+ }
+ impl ::hash::Hash for fpreg32 {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.fpr_env.hash(state);
+ self.fpr_acc.hash(state);
+ self.fpr_ex_sw.hash(state);
+ self.fpr_pad.hash(state);
+ }
+ }
+
+ impl PartialEq for fpreg {
+ fn eq(&self, other: &fpreg) -> bool {
+ self.fpr_env == other.fpr_env &&
+ self.fpr_acc == other.fpr_acc &&
+ self.fpr_xacc == other.fpr_xacc &&
+ self.fpr_spare == other.fpr_spare
+ }
+ }
+ impl Eq for fpreg {}
+ impl ::fmt::Debug for fpreg {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("fpreg")
+ .field("fpr_env", &self.fpr_env)
+ .field("fpr_acc", &self.fpr_acc)
+ .field("fpr_xacc", &self.fpr_xacc)
+ .field("fpr_spare", &self.fpr_spare)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for fpreg {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.fpr_env.hash(state);
+ self.fpr_acc.hash(state);
+ self.fpr_xacc.hash(state);
+ self.fpr_spare.hash(state);
+ }
+ }
+
+ impl PartialEq for xmmreg {
+ fn eq(&self, other: &xmmreg) -> bool {
+ self.xmm_env == other.xmm_env &&
+ self.xmm_acc == other.xmm_acc &&
+ self.xmm_reg == other.xmm_reg &&
+ self.xmm_pad
+ .iter()
+ .zip(other.xmm_pad.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for xmmreg {}
+ impl ::fmt::Debug for xmmreg {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("xmmreg")
+ .field("xmm_env", &self.xmm_env)
+ .field("xmm_acc", &self.xmm_acc)
+ .field("xmm_reg", &self.xmm_reg)
+ .field("xmm_pad", &&self.xmm_pad[..])
+ .finish()
+ }
+ }
+ impl ::hash::Hash for xmmreg {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.xmm_env.hash(state);
+ self.xmm_acc.hash(state);
+ self.xmm_reg.hash(state);
+ self.xmm_pad.hash(state);
+ }
+ }
+ }
+}
+
// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {