diff options
author | David Carlier <devnexen@gmail.com> | 2021-08-28 20:32:00 +0100 |
---|---|---|
committer | David Carlier <devnexen@gmail.com> | 2021-08-28 20:32:00 +0100 |
commit | aba93f8029dcb4a91075e67b70bb198fc78b2e91 (patch) | |
tree | 6cadcc0f23597a84d5a34d4528ce734246b52be1 | |
parent | f01492db1baf5a468d0ee7075b8aef96a3834062 (diff) | |
download | rust-libc-aba93f8029dcb4a91075e67b70bb198fc78b2e91.tar.gz |
netbsd ucontext type for arm64
-rw-r--r-- | libc-test/build.rs | 3 | ||||
-rw-r--r-- | libc-test/semver/netbsd-aarch64.txt | 3 | ||||
-rw-r--r-- | src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 81 |
3 files changed, 87 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index 5d1b8dfcfb..2d57019719 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1032,6 +1032,9 @@ fn test_netbsd(target: &str) { }); cfg.skip_type(move |ty| { + if ty.starts_with("__c_anonymous_") { + return true; + } match ty { // FIXME: sighandler_t is crazy across platforms "sighandler_t" => true, diff --git a/libc-test/semver/netbsd-aarch64.txt b/libc-test/semver/netbsd-aarch64.txt index d64531a1e9..e48c529a96 100644 --- a/libc-test/semver/netbsd-aarch64.txt +++ b/libc-test/semver/netbsd-aarch64.txt @@ -2,3 +2,6 @@ PT_GETFPREGS PT_GETREGS PT_SETFPREGS PT_SETREGS +__fregset +mcontext_t +ucontext_t diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index 58c4cf7c45..7b895f6323 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -3,8 +3,89 @@ use PT_FIRSTMACH; pub type c_long = i64; pub type c_ulong = u64; pub type c_char = u8; +pub type greg_t = u64; pub type __cpu_simple_lock_nv_t = ::c_uchar; +s! { + pub struct __fregset { + #[cfg(libc_union)] + pub __qregs: [__c_anonymous__freg; 32], + pub __fpcr: u32, + pub __fpsr: u32, + } + + pub struct mcontext_t { + pub __gregs: [::greg_t; 32], + pub __fregs: __fregset, + __spare: [::greg_t; 8], + } + + pub struct ucontext_t { + pub uc_flags: ::c_uint, + pub uc_link: *mut ucontext_t, + pub uc_sigmask: ::sigset_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + } +} + +s_no_extra_traits! { + #[cfg(libc_union)] + #[repr(align(16))] + pub union __c_anonymous__freg { + pub __b8: [u8; 16], + pub __h16: [u16; 8], + pub __s32: [u32; 4], + pub __d64: [u64; 2], + pub __q128: [u128; 1], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + #[cfg(libc_union)] + impl PartialEq for __c_anonymous__freg { + fn eq(&self, other: &__c_anonymous__freg) -> bool { + unsafe { + self.__b8 == other.__b8 + || self.__h16 == other.__h16 + || self.__s32 == other.__s32 + || self.__d64 == other.__d64 + || self.__q128 == other.__q128 + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous__freg {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous__freg { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous__freg") + .field("__b8", &self.__b8) + .field("__h16", &self.__h16) + .field("__s32", &self.__s32) + .field("__d64", &self.__d64) + .field("__q128", &self.__q128) + .finish() + } + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous__freg { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.__b8.hash(state); + self.__h16.hash(state); + self.__s32.hash(state); + self.__d64.hash(state); + self.__q128.hash(state); + } + } + } + } +} + // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { |