Skip to content

[0.2] Backports #4006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 7, 2024
2 changes: 0 additions & 2 deletions libc-test/semver/freebsd-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ _MC_HASSEGS
fpreg
fpreg32
max_align_t
mcontext_t
reg
reg32
ucontext_t
xmmreg
2 changes: 2 additions & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,7 @@ mallctl
mallctlbymib
mallctlnametomib
mallocx
mcontext_t
memmem
memrchr
memset_s
Expand Down Expand Up @@ -2358,6 +2359,7 @@ timer_t
timex
truncate
ttyname_r
ucontext_t
unmount
useconds_t
uselocale
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ pub const TIOCISPTMASTER: ::c_ulong = 0x20007455;
pub const TIOCMODG: ::c_ulong = 0x40047403;
pub const TIOCMODS: ::c_ulong = 0x80047404;
pub const TIOCREMOTE: ::c_ulong = 0x80047469;
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;

// Constants used by "at" family of system calls.
pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor
Expand Down
4 changes: 4 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type clock_t = i32;
pub type wchar_t = u32;
pub type time_t = i64;
pub type suseconds_t = i64;
Expand Down Expand Up @@ -142,5 +143,8 @@ cfg_if! {
}
}

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
48 changes: 48 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/arm.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
pub type c_char = u8;
pub type c_long = i32;
pub type c_ulong = u32;
pub type clock_t = u32;
pub type wchar_t = u32;
pub type time_t = i64;
pub type suseconds_t = i32;
pub type register_t = i32;
pub type __greg_t = ::c_uint;
pub type __gregset_t = [::__greg_t; 17];

s_no_extra_traits! {
pub struct mcontext_t {
pub __gregs: ::__gregset_t,
pub mc_vfp_size: ::__size_t,
pub mc_vfp_ptr: *mut ::c_void,
pub mc_spare: [::c_uint; 33],
}
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.__gregs == other.__gregs &&
self.mc_vfp_size == other.mc_vfp_size &&
self.mc_vfp_ptr == other.mc_vfp_ptr &&
self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b)
}
}
impl Eq for mcontext_t {}
impl ::fmt::Debug for mcontext_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("mcontext_t")
.field("__gregs", &self.__gregs)
.field("mc_vfp_size", &self.mc_vfp_size)
.field("mc_vfp_ptr", &self.mc_vfp_ptr)
.field("mc_spare", &self.mc_spare)
.finish()
}
}
impl ::hash::Hash for mcontext_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.__gregs.hash(state);
self.mc_vfp_size.hash(state);
self.mc_vfp_ptr.hash(state);
self.mc_spare.hash(state);
}
}
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
Expand All @@ -16,5 +60,9 @@ cfg_if! {
pub const _ALIGNBYTES: usize = 4 - 1;
}
}

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
5 changes: 4 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ s! {
}

pub struct __c_anonymous_domainset {
_priv: [::uintptr_t; 4],
#[cfg(target_pointer_width = "64")]
_priv: [::c_ulong; 4],
#[cfg(target_pointer_width = "32")]
_priv: [::c_ulong; 8],
}

pub struct kinfo_proc {
Expand Down
5 changes: 4 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ s! {
}

pub struct __c_anonymous_domainset {
_priv: [::uintptr_t; 4],
#[cfg(target_pointer_width = "64")]
_priv: [::c_ulong; 4],
#[cfg(target_pointer_width = "32")]
_priv: [::c_ulong; 8],
}

pub struct kinfo_proc {
Expand Down
5 changes: 4 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ s! {
}

pub struct __c_anonymous_domainset {
_priv: [::uintptr_t; 4],
#[cfg(target_pointer_width = "64")]
_priv: [::c_ulong; 4],
#[cfg(target_pointer_width = "32")]
_priv: [::c_ulong; 8],
}

pub struct kinfo_proc {
Expand Down
43 changes: 39 additions & 4 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub type fflags_t = u32;
pub type clock_t = i32;

pub type vm_prot_t = u_char;
pub type kvaddr_t = u64;
Expand Down Expand Up @@ -1646,14 +1645,24 @@ s_no_extra_traits! {
pub kf_flags: ::c_int,
_kf_pad0: ::c_int,
pub kf_offset: i64,
_priv: [::uintptr_t; 38], // FIXME if needed
_priv: [u8; 304], // FIXME: this is really a giant union
pub kf_status: u16,
_kf_pad1: u16,
_kf_ispare0: ::c_int,
pub kf_cap_rights: ::cap_rights_t,
_kf_cap_spare: u64,
pub kf_path: [::c_char; ::PATH_MAX as usize],
}

pub struct ucontext_t {
pub uc_sigmask: ::sigset_t,
#[cfg(libc_align)]
pub uc_mcontext: ::mcontext_t,
pub uc_link: *mut ::ucontext_t,
pub uc_stack: ::stack_t,
pub uc_flags: ::c_int,
__spare__: [::c_int; 4],
}
}

cfg_if! {
Expand Down Expand Up @@ -2656,6 +2665,19 @@ cfg_if! {
self.kf_path.hash(state);
}
}

impl ::fmt::Debug for ucontext_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ucontext_t")
.field("uc_sigmask", &self.uc_sigmask)
// FIXME: enable when libc_align is dropped
// .field("uc_mcontext", &self.uc_mcontext)
.field("uc_link", &self.uc_link)
.field("uc_stack", &self.uc_stack)
.field("uc_flags", &self.uc_flags)
.finish()
}
}
}
}

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

pub const VM_TOTAL: ::c_int = 1;

pub const BIOCSETFNR: ::c_ulong = 0x80104282;
cfg_if! {
if #[cfg(target_pointer_width = "64")] {
pub const BIOCSETFNR: ::c_ulong = 0x80104282;
} else {
pub const BIOCSETFNR: ::c_ulong = 0x80084282;
}
}

cfg_if! {
if #[cfg(target_pointer_width = "64")] {
pub const FIODGNAME: ::c_ulong = 0x80106678;
} else {
pub const FIODGNAME: ::c_ulong = 0x80086678;
}
}

pub const FIODGNAME: ::c_ulong = 0x80106678;
pub const FIONWRITE: ::c_ulong = 0x40046677;
pub const FIONSPACE: ::c_ulong = 0x40046676;
pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
Expand Down
70 changes: 70 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/powerpc.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,78 @@
pub type c_char = u8;
pub type c_long = i32;
pub type c_ulong = u32;
pub type clock_t = u32;
pub type wchar_t = i32;
pub type time_t = i64;
pub type suseconds_t = i32;
pub type register_t = i32;

cfg_if! {
if #[cfg(libc_align)] {
s_no_extra_traits! {
#[repr(align(16))]
pub struct mcontext_t {
pub mc_vers: ::c_int,
pub mc_flags: ::c_int,
pub mc_onstack: ::c_int,
pub mc_len: ::c_int,
pub mc_avec: [u64; 64],
pub mc_av: [u32; 2],
pub mc_frame: [::register_t; 42],
pub mc_fpreg: [u64; 33],
pub mc_vsxfpreg: [u64; 32],
}
}
}
}

cfg_if! {
if #[cfg(all(libc_align, feature = "extra_traits"))] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_vers == other.mc_vers &&
self.mc_flags == other.mc_flags &&
self.mc_onstack == other.mc_onstack &&
self.mc_len == other.mc_len &&
self.mc_avec == other.mc_avec &&
self.mc_av == other.mc_av &&
self.mc_frame == other.mc_frame &&
self.mc_fpreg == other.mc_fpreg &&
self.mc_vsxfpreg == other.mc_vsxfpreg
}
}
impl Eq for mcontext_t {}
impl ::fmt::Debug for mcontext_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("mcontext_t")
.field("mc_vers", &self.mc_vers)
.field("mc_flags", &self.mc_flags)
.field("mc_onstack", &self.mc_onstack)
.field("mc_len", &self.mc_len)
.field("mc_avec", &self.mc_avec)
.field("mc_av", &self.mc_av)
.field("mc_frame", &self.mc_frame)
.field("mc_fpreg", &self.mc_fpreg)
.field("mc_vsxfpreg", &self.mc_vsxfpreg)
.finish()
}
}
impl ::hash::Hash for mcontext_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.mc_vers.hash(state);
self.mc_flags.hash(state);
self.mc_onstack.hash(state);
self.mc_len.hash(state);
self.mc_avec.hash(state);
self.mc_av.hash(state);
self.mc_frame.hash(state);
self.mc_fpreg.hash(state);
self.mc_vsxfpreg.hash(state);
}
}
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
Expand All @@ -17,5 +84,8 @@ cfg_if! {
}
}

pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
pub const MAP_32BIT: ::c_int = 0x00080000;
pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
Loading