Skip to content

Commit d435e9b

Browse files
authored
Merge pull request #4006 from tgross35/backport-spinach
[0.2] Backports
2 parents 7ee37b9 + 073c7b4 commit d435e9b

File tree

17 files changed

+314
-72
lines changed

17 files changed

+314
-72
lines changed

libc-test/semver/freebsd-x86_64.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ _MC_HASSEGS
1313
fpreg
1414
fpreg32
1515
max_align_t
16-
mcontext_t
1716
reg
1817
reg32
19-
ucontext_t
2018
xmmreg

libc-test/semver/freebsd.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,7 @@ mallctl
20282028
mallctlbymib
20292029
mallctlnametomib
20302030
mallocx
2031+
mcontext_t
20312032
memmem
20322033
memrchr
20332034
memset_s
@@ -2358,6 +2359,7 @@ timer_t
23582359
timex
23592360
truncate
23602361
ttyname_r
2362+
ucontext_t
23612363
unmount
23622364
useconds_t
23632365
uselocale

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ pub const TIOCISPTMASTER: ::c_ulong = 0x20007455;
14621462
pub const TIOCMODG: ::c_ulong = 0x40047403;
14631463
pub const TIOCMODS: ::c_ulong = 0x80047404;
14641464
pub const TIOCREMOTE: ::c_ulong = 0x80047469;
1465+
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
14651466

14661467
// Constants used by "at" family of system calls.
14671468
pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor

src/unix/bsd/freebsdlike/freebsd/aarch64.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub type c_char = u8;
22
pub type c_long = i64;
33
pub type c_ulong = u64;
4+
pub type clock_t = i32;
45
pub type wchar_t = u32;
56
pub type time_t = i64;
67
pub type suseconds_t = i64;
@@ -142,5 +143,8 @@ cfg_if! {
142143
}
143144
}
144145

146+
pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
147+
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
145148
pub const MAP_32BIT: ::c_int = 0x00080000;
146149
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
150+
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;

src/unix/bsd/freebsdlike/freebsd/arm.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
11
pub type c_char = u8;
22
pub type c_long = i32;
33
pub type c_ulong = u32;
4+
pub type clock_t = u32;
45
pub type wchar_t = u32;
56
pub type time_t = i64;
67
pub type suseconds_t = i32;
78
pub type register_t = i32;
9+
pub type __greg_t = ::c_uint;
10+
pub type __gregset_t = [::__greg_t; 17];
11+
12+
s_no_extra_traits! {
13+
pub struct mcontext_t {
14+
pub __gregs: ::__gregset_t,
15+
pub mc_vfp_size: ::__size_t,
16+
pub mc_vfp_ptr: *mut ::c_void,
17+
pub mc_spare: [::c_uint; 33],
18+
}
19+
}
20+
21+
cfg_if! {
22+
if #[cfg(feature = "extra_traits")] {
23+
impl PartialEq for mcontext_t {
24+
fn eq(&self, other: &mcontext_t) -> bool {
25+
self.__gregs == other.__gregs &&
26+
self.mc_vfp_size == other.mc_vfp_size &&
27+
self.mc_vfp_ptr == other.mc_vfp_ptr &&
28+
self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b)
29+
}
30+
}
31+
impl Eq for mcontext_t {}
32+
impl ::fmt::Debug for mcontext_t {
33+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
34+
f.debug_struct("mcontext_t")
35+
.field("__gregs", &self.__gregs)
36+
.field("mc_vfp_size", &self.mc_vfp_size)
37+
.field("mc_vfp_ptr", &self.mc_vfp_ptr)
38+
.field("mc_spare", &self.mc_spare)
39+
.finish()
40+
}
41+
}
42+
impl ::hash::Hash for mcontext_t {
43+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
44+
self.__gregs.hash(state);
45+
self.mc_vfp_size.hash(state);
46+
self.mc_vfp_ptr.hash(state);
47+
self.mc_spare.hash(state);
48+
}
49+
}
50+
}
51+
}
852

953
// should be pub(crate), but that requires Rust 1.18.0
1054
cfg_if! {
@@ -16,5 +60,9 @@ cfg_if! {
1660
pub const _ALIGNBYTES: usize = 4 - 1;
1761
}
1862
}
63+
64+
pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
65+
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
1966
pub const MAP_32BIT: ::c_int = 0x00080000;
2067
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
68+
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;

src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ s! {
4141
}
4242

4343
pub struct __c_anonymous_domainset {
44-
_priv: [::uintptr_t; 4],
44+
#[cfg(target_pointer_width = "64")]
45+
_priv: [::c_ulong; 4],
46+
#[cfg(target_pointer_width = "32")]
47+
_priv: [::c_ulong; 8],
4548
}
4649

4750
pub struct kinfo_proc {

src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ s! {
4141
}
4242

4343
pub struct __c_anonymous_domainset {
44-
_priv: [::uintptr_t; 4],
44+
#[cfg(target_pointer_width = "64")]
45+
_priv: [::c_ulong; 4],
46+
#[cfg(target_pointer_width = "32")]
47+
_priv: [::c_ulong; 8],
4548
}
4649

4750
pub struct kinfo_proc {

src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ s! {
4141
}
4242

4343
pub struct __c_anonymous_domainset {
44-
_priv: [::uintptr_t; 4],
44+
#[cfg(target_pointer_width = "64")]
45+
_priv: [::c_ulong; 4],
46+
#[cfg(target_pointer_width = "32")]
47+
_priv: [::c_ulong; 8],
4548
}
4649

4750
pub struct kinfo_proc {

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub type fflags_t = u32;
2-
pub type clock_t = i32;
32

43
pub type vm_prot_t = u_char;
54
pub type kvaddr_t = u64;
@@ -1646,14 +1645,24 @@ s_no_extra_traits! {
16461645
pub kf_flags: ::c_int,
16471646
_kf_pad0: ::c_int,
16481647
pub kf_offset: i64,
1649-
_priv: [::uintptr_t; 38], // FIXME if needed
1648+
_priv: [u8; 304], // FIXME: this is really a giant union
16501649
pub kf_status: u16,
16511650
_kf_pad1: u16,
16521651
_kf_ispare0: ::c_int,
16531652
pub kf_cap_rights: ::cap_rights_t,
16541653
_kf_cap_spare: u64,
16551654
pub kf_path: [::c_char; ::PATH_MAX as usize],
16561655
}
1656+
1657+
pub struct ucontext_t {
1658+
pub uc_sigmask: ::sigset_t,
1659+
#[cfg(libc_align)]
1660+
pub uc_mcontext: ::mcontext_t,
1661+
pub uc_link: *mut ::ucontext_t,
1662+
pub uc_stack: ::stack_t,
1663+
pub uc_flags: ::c_int,
1664+
__spare__: [::c_int; 4],
1665+
}
16571666
}
16581667

16591668
cfg_if! {
@@ -2656,6 +2665,19 @@ cfg_if! {
26562665
self.kf_path.hash(state);
26572666
}
26582667
}
2668+
2669+
impl ::fmt::Debug for ucontext_t {
2670+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
2671+
f.debug_struct("ucontext_t")
2672+
.field("uc_sigmask", &self.uc_sigmask)
2673+
// FIXME: enable when libc_align is dropped
2674+
// .field("uc_mcontext", &self.uc_mcontext)
2675+
.field("uc_link", &self.uc_link)
2676+
.field("uc_stack", &self.uc_stack)
2677+
.field("uc_flags", &self.uc_flags)
2678+
.finish()
2679+
}
2680+
}
26592681
}
26602682
}
26612683

@@ -3189,9 +3211,22 @@ pub const H4DISC: ::c_int = 0x7;
31893211

31903212
pub const VM_TOTAL: ::c_int = 1;
31913213

3192-
pub const BIOCSETFNR: ::c_ulong = 0x80104282;
3214+
cfg_if! {
3215+
if #[cfg(target_pointer_width = "64")] {
3216+
pub const BIOCSETFNR: ::c_ulong = 0x80104282;
3217+
} else {
3218+
pub const BIOCSETFNR: ::c_ulong = 0x80084282;
3219+
}
3220+
}
3221+
3222+
cfg_if! {
3223+
if #[cfg(target_pointer_width = "64")] {
3224+
pub const FIODGNAME: ::c_ulong = 0x80106678;
3225+
} else {
3226+
pub const FIODGNAME: ::c_ulong = 0x80086678;
3227+
}
3228+
}
31933229

3194-
pub const FIODGNAME: ::c_ulong = 0x80106678;
31953230
pub const FIONWRITE: ::c_ulong = 0x40046677;
31963231
pub const FIONSPACE: ::c_ulong = 0x40046676;
31973232
pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;

src/unix/bsd/freebsdlike/freebsd/powerpc.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,78 @@
11
pub type c_char = u8;
22
pub type c_long = i32;
33
pub type c_ulong = u32;
4+
pub type clock_t = u32;
45
pub type wchar_t = i32;
56
pub type time_t = i64;
67
pub type suseconds_t = i32;
78
pub type register_t = i32;
89

10+
cfg_if! {
11+
if #[cfg(libc_align)] {
12+
s_no_extra_traits! {
13+
#[repr(align(16))]
14+
pub struct mcontext_t {
15+
pub mc_vers: ::c_int,
16+
pub mc_flags: ::c_int,
17+
pub mc_onstack: ::c_int,
18+
pub mc_len: ::c_int,
19+
pub mc_avec: [u64; 64],
20+
pub mc_av: [u32; 2],
21+
pub mc_frame: [::register_t; 42],
22+
pub mc_fpreg: [u64; 33],
23+
pub mc_vsxfpreg: [u64; 32],
24+
}
25+
}
26+
}
27+
}
28+
29+
cfg_if! {
30+
if #[cfg(all(libc_align, feature = "extra_traits"))] {
31+
impl PartialEq for mcontext_t {
32+
fn eq(&self, other: &mcontext_t) -> bool {
33+
self.mc_vers == other.mc_vers &&
34+
self.mc_flags == other.mc_flags &&
35+
self.mc_onstack == other.mc_onstack &&
36+
self.mc_len == other.mc_len &&
37+
self.mc_avec == other.mc_avec &&
38+
self.mc_av == other.mc_av &&
39+
self.mc_frame == other.mc_frame &&
40+
self.mc_fpreg == other.mc_fpreg &&
41+
self.mc_vsxfpreg == other.mc_vsxfpreg
42+
}
43+
}
44+
impl Eq for mcontext_t {}
45+
impl ::fmt::Debug for mcontext_t {
46+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
47+
f.debug_struct("mcontext_t")
48+
.field("mc_vers", &self.mc_vers)
49+
.field("mc_flags", &self.mc_flags)
50+
.field("mc_onstack", &self.mc_onstack)
51+
.field("mc_len", &self.mc_len)
52+
.field("mc_avec", &self.mc_avec)
53+
.field("mc_av", &self.mc_av)
54+
.field("mc_frame", &self.mc_frame)
55+
.field("mc_fpreg", &self.mc_fpreg)
56+
.field("mc_vsxfpreg", &self.mc_vsxfpreg)
57+
.finish()
58+
}
59+
}
60+
impl ::hash::Hash for mcontext_t {
61+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
62+
self.mc_vers.hash(state);
63+
self.mc_flags.hash(state);
64+
self.mc_onstack.hash(state);
65+
self.mc_len.hash(state);
66+
self.mc_avec.hash(state);
67+
self.mc_av.hash(state);
68+
self.mc_frame.hash(state);
69+
self.mc_fpreg.hash(state);
70+
self.mc_vsxfpreg.hash(state);
71+
}
72+
}
73+
}
74+
}
75+
976
// should be pub(crate), but that requires Rust 1.18.0
1077
cfg_if! {
1178
if #[cfg(libc_const_size_of)] {
@@ -17,5 +84,8 @@ cfg_if! {
1784
}
1885
}
1986

87+
pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
88+
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
2089
pub const MAP_32BIT: ::c_int = 0x00080000;
2190
pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
91+
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;

0 commit comments

Comments
 (0)