Skip to content

Commit 16df9e0

Browse files
committed
Auto merge of #2377 - devnexen:netbsd_arm64, r=JohnTitor
netbsd ucontext type for arm64
2 parents 2849541 + aba93f8 commit 16df9e0

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,9 @@ fn test_netbsd(target: &str) {
10321032
});
10331033

10341034
cfg.skip_type(move |ty| {
1035+
if ty.starts_with("__c_anonymous_") {
1036+
return true;
1037+
}
10351038
match ty {
10361039
// FIXME: sighandler_t is crazy across platforms
10371040
"sighandler_t" => true,

libc-test/semver/netbsd-aarch64.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ PT_GETFPREGS
22
PT_GETREGS
33
PT_SETFPREGS
44
PT_SETREGS
5+
__fregset
6+
mcontext_t
7+
ucontext_t

src/unix/bsd/netbsdlike/netbsd/aarch64.rs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,89 @@ use PT_FIRSTMACH;
33
pub type c_long = i64;
44
pub type c_ulong = u64;
55
pub type c_char = u8;
6+
pub type greg_t = u64;
67
pub type __cpu_simple_lock_nv_t = ::c_uchar;
78

9+
s! {
10+
pub struct __fregset {
11+
#[cfg(libc_union)]
12+
pub __qregs: [__c_anonymous__freg; 32],
13+
pub __fpcr: u32,
14+
pub __fpsr: u32,
15+
}
16+
17+
pub struct mcontext_t {
18+
pub __gregs: [::greg_t; 32],
19+
pub __fregs: __fregset,
20+
__spare: [::greg_t; 8],
21+
}
22+
23+
pub struct ucontext_t {
24+
pub uc_flags: ::c_uint,
25+
pub uc_link: *mut ucontext_t,
26+
pub uc_sigmask: ::sigset_t,
27+
pub uc_stack: ::stack_t,
28+
pub uc_mcontext: mcontext_t,
29+
}
30+
}
31+
32+
s_no_extra_traits! {
33+
#[cfg(libc_union)]
34+
#[repr(align(16))]
35+
pub union __c_anonymous__freg {
36+
pub __b8: [u8; 16],
37+
pub __h16: [u16; 8],
38+
pub __s32: [u32; 4],
39+
pub __d64: [u64; 2],
40+
pub __q128: [u128; 1],
41+
}
42+
}
43+
44+
cfg_if! {
45+
if #[cfg(feature = "extra_traits")] {
46+
#[cfg(libc_union)]
47+
impl PartialEq for __c_anonymous__freg {
48+
fn eq(&self, other: &__c_anonymous__freg) -> bool {
49+
unsafe {
50+
self.__b8 == other.__b8
51+
|| self.__h16 == other.__h16
52+
|| self.__s32 == other.__s32
53+
|| self.__d64 == other.__d64
54+
|| self.__q128 == other.__q128
55+
}
56+
}
57+
}
58+
#[cfg(libc_union)]
59+
impl Eq for __c_anonymous__freg {}
60+
#[cfg(libc_union)]
61+
impl ::fmt::Debug for __c_anonymous__freg {
62+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
63+
unsafe {
64+
f.debug_struct("__c_anonymous__freg")
65+
.field("__b8", &self.__b8)
66+
.field("__h16", &self.__h16)
67+
.field("__s32", &self.__s32)
68+
.field("__d64", &self.__d64)
69+
.field("__q128", &self.__q128)
70+
.finish()
71+
}
72+
}
73+
}
74+
#[cfg(libc_union)]
75+
impl ::hash::Hash for __c_anonymous__freg {
76+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
77+
unsafe {
78+
self.__b8.hash(state);
79+
self.__h16.hash(state);
80+
self.__s32.hash(state);
81+
self.__d64.hash(state);
82+
self.__q128.hash(state);
83+
}
84+
}
85+
}
86+
}
87+
}
88+
889
// should be pub(crate), but that requires Rust 1.18.0
990
cfg_if! {
1091
if #[cfg(libc_const_size_of)] {

0 commit comments

Comments
 (0)