Skip to content

Commit b5aeb93

Browse files
committed
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.
1 parent c8a0faf commit b5aeb93

File tree

2 files changed

+41
-35
lines changed

2 files changed

+41
-35
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ s_no_extra_traits! {
16571657

16581658
pub struct ucontext_t {
16591659
pub uc_sigmask: ::sigset_t,
1660+
#[cfg(libc_align)]
16601661
pub uc_mcontext: ::mcontext_t,
16611662
pub uc_link: *mut ::ucontext_t,
16621663
pub uc_stack: ::stack_t,
@@ -2670,7 +2671,8 @@ cfg_if! {
26702671
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
26712672
f.debug_struct("ucontext_t")
26722673
.field("uc_sigmask", &self.uc_sigmask)
2673-
.field("uc_mcontext", &self.uc_mcontext)
2674+
// FIXME: enable when libc_align is dropped
2675+
// .field("uc_mcontext", &self.uc_mcontext)
26742676
.field("uc_link", &self.uc_link)
26752677
.field("uc_stack", &self.uc_stack)
26762678
.field("uc_flags", &self.uc_flags)

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

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,43 @@ pub type time_t = i32;
66
pub type suseconds_t = i32;
77
pub type register_t = i32;
88

9-
s_no_extra_traits! {
10-
#[repr(align(16))]
11-
pub struct mcontext_t {
12-
pub mc_onstack: register_t,
13-
pub mc_gs: register_t,
14-
pub mc_fs: register_t,
15-
pub mc_es: register_t,
16-
pub mc_ds: register_t,
17-
pub mc_edi: register_t,
18-
pub mc_esi: register_t,
19-
pub mc_ebp: register_t,
20-
pub mc_isp: register_t,
21-
pub mc_ebx: register_t,
22-
pub mc_edx: register_t,
23-
pub mc_ecx: register_t,
24-
pub mc_eax: register_t,
25-
pub mc_trapno: register_t,
26-
pub mc_err: register_t,
27-
pub mc_eip: register_t,
28-
pub mc_cs: register_t,
29-
pub mc_eflags: register_t,
30-
pub mc_esp: register_t,
31-
pub mc_ss: register_t,
32-
pub mc_len: ::c_int,
33-
pub mc_fpformat: ::c_int,
34-
pub mc_ownedfp: ::c_int,
35-
pub mc_flags: register_t,
36-
pub mc_fpstate: [::c_int; 128],
37-
pub mc_fsbase: register_t,
38-
pub mc_gsbase: register_t,
39-
pub mc_xfpustate: register_t,
40-
pub mc_xfpustate_len: register_t,
41-
pub mc_spare2: [::c_int; 4],
9+
cfg_if! {
10+
if #[cfg(libc_align)] {
11+
s_no_extra_traits! {
12+
#[repr(align(16))]
13+
pub struct mcontext_t {
14+
pub mc_onstack: register_t,
15+
pub mc_gs: register_t,
16+
pub mc_fs: register_t,
17+
pub mc_es: register_t,
18+
pub mc_ds: register_t,
19+
pub mc_edi: register_t,
20+
pub mc_esi: register_t,
21+
pub mc_ebp: register_t,
22+
pub mc_isp: register_t,
23+
pub mc_ebx: register_t,
24+
pub mc_edx: register_t,
25+
pub mc_ecx: register_t,
26+
pub mc_eax: register_t,
27+
pub mc_trapno: register_t,
28+
pub mc_err: register_t,
29+
pub mc_eip: register_t,
30+
pub mc_cs: register_t,
31+
pub mc_eflags: register_t,
32+
pub mc_esp: register_t,
33+
pub mc_ss: register_t,
34+
pub mc_len: ::c_int,
35+
pub mc_fpformat: ::c_int,
36+
pub mc_ownedfp: ::c_int,
37+
pub mc_flags: register_t,
38+
pub mc_fpstate: [::c_int; 128],
39+
pub mc_fsbase: register_t,
40+
pub mc_gsbase: register_t,
41+
pub mc_xfpustate: register_t,
42+
pub mc_xfpustate_len: register_t,
43+
pub mc_spare2: [::c_int; 4],
44+
}
45+
}
4246
}
4347
}
4448

@@ -54,7 +58,7 @@ cfg_if! {
5458
}
5559

5660
cfg_if! {
57-
if #[cfg(feature = "extra_traits")] {
61+
if #[cfg(all(libc_align, feature = "extra_traits"))] {
5862
impl PartialEq for mcontext_t {
5963
fn eq(&self, other: &mcontext_t) -> bool {
6064
self.mc_onstack == other.mc_onstack &&

0 commit comments

Comments
 (0)