Skip to content
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

[0.2] Backports #4006

Merged
merged 11 commits into from
Nov 7, 2024
Prev Previous commit
Next Next commit
Gate FreeBSD mcontext_t under libc_align
Enable this backport by just dropping support for FreeBSD mcontext_t
without `libc_align`, i.e. with Rust < 1.25 (2018). This is sufficiently
niche that it is not worth adding a new `align` module.
  • Loading branch information
tgross35 committed Nov 7, 2024
commit b5aeb939e7c5205569a4364b81f627a843d7aa76
4 changes: 3 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ s_no_extra_traits! {

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,
Expand Down Expand Up @@ -2670,7 +2671,8 @@ cfg_if! {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ucontext_t")
.field("uc_sigmask", &self.uc_sigmask)
.field("uc_mcontext", &self.uc_mcontext)
// 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)
Expand Down
72 changes: 38 additions & 34 deletions src/unix/bsd/freebsdlike/freebsd/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,43 @@ pub type time_t = i32;
pub type suseconds_t = i32;
pub type register_t = i32;

s_no_extra_traits! {
#[repr(align(16))]
pub struct mcontext_t {
pub mc_onstack: register_t,
pub mc_gs: register_t,
pub mc_fs: register_t,
pub mc_es: register_t,
pub mc_ds: register_t,
pub mc_edi: register_t,
pub mc_esi: register_t,
pub mc_ebp: register_t,
pub mc_isp: register_t,
pub mc_ebx: register_t,
pub mc_edx: register_t,
pub mc_ecx: register_t,
pub mc_eax: register_t,
pub mc_trapno: register_t,
pub mc_err: register_t,
pub mc_eip: register_t,
pub mc_cs: register_t,
pub mc_eflags: register_t,
pub mc_esp: register_t,
pub mc_ss: register_t,
pub mc_len: ::c_int,
pub mc_fpformat: ::c_int,
pub mc_ownedfp: ::c_int,
pub mc_flags: register_t,
pub mc_fpstate: [::c_int; 128],
pub mc_fsbase: register_t,
pub mc_gsbase: register_t,
pub mc_xfpustate: register_t,
pub mc_xfpustate_len: register_t,
pub mc_spare2: [::c_int; 4],
cfg_if! {
if #[cfg(libc_align)] {
s_no_extra_traits! {
#[repr(align(16))]
pub struct mcontext_t {
pub mc_onstack: register_t,
pub mc_gs: register_t,
pub mc_fs: register_t,
pub mc_es: register_t,
pub mc_ds: register_t,
pub mc_edi: register_t,
pub mc_esi: register_t,
pub mc_ebp: register_t,
pub mc_isp: register_t,
pub mc_ebx: register_t,
pub mc_edx: register_t,
pub mc_ecx: register_t,
pub mc_eax: register_t,
pub mc_trapno: register_t,
pub mc_err: register_t,
pub mc_eip: register_t,
pub mc_cs: register_t,
pub mc_eflags: register_t,
pub mc_esp: register_t,
pub mc_ss: register_t,
pub mc_len: ::c_int,
pub mc_fpformat: ::c_int,
pub mc_ownedfp: ::c_int,
pub mc_flags: register_t,
pub mc_fpstate: [::c_int; 128],
pub mc_fsbase: register_t,
pub mc_gsbase: register_t,
pub mc_xfpustate: register_t,
pub mc_xfpustate_len: register_t,
pub mc_spare2: [::c_int; 4],
}
}
}
}

Expand All @@ -54,7 +58,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
if #[cfg(all(libc_align, feature = "extra_traits"))] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_onstack == other.mc_onstack &&
Expand Down