Skip to content

Commit

Permalink
musl: Unify definitions of siginfo_t
Browse files Browse the repository at this point in the history
Musl provides a single definition for `siginfo_t` [1] with the order of
`si_code` and `si_errno` controlled by `__SI_SWAP_ERRNO_CODE`. This is
only set on mips (both 32- and 64-bit).

[1]: https://github.com/kraj/musl/blob/ffb23aef7b5339b8c3234f4c6a93c488dc873919/include/signal.h#L99-L147

[ extracted from "Remove all redundant definitions in musl backend", add
  context to the commit message - Trevor ]
  • Loading branch information
bossmc authored and tgross35 committed Nov 25, 2024
1 parent 6c0952e commit e1ff5d6
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 78 deletions.
8 changes: 0 additions & 8 deletions src/unix/linux_like/linux/musl/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ s! {
pub f_spare: [::c_ulong; 4],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
pub _pad: [::c_int; 29],
_align: [usize; 0],
}

pub struct statfs64 {
pub f_type: ::c_ulong,
pub f_bsize: ::c_ulong,
Expand Down
8 changes: 0 additions & 8 deletions src/unix/linux_like/linux/musl/b32/hexagon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ s! {
pub f_spare: [::c_ulong; 4],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
pub _pad: [::c_int; 29],
_align: [usize; 0],
}

pub struct statfs64 {
pub f_type: ::c_ulong,
pub f_bsize: ::c_ulong,
Expand Down
8 changes: 0 additions & 8 deletions src/unix/linux_like/linux/musl/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ s! {
pub f_spare: [::c_ulong; 5],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_code: ::c_int,
pub si_errno: ::c_int,
pub _pad: [::c_int; 29],
_align: [usize; 0],
}

pub struct statfs64 {
pub f_type: ::c_ulong,
pub f_bsize: ::c_ulong,
Expand Down
8 changes: 0 additions & 8 deletions src/unix/linux_like/linux/musl/b32/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ s! {
pub f_spare: [::c_ulong; 4],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
pub _pad: [::c_int; 29],
_align: [usize; 0],
}

pub struct statfs64 {
pub f_type: ::c_ulong,
pub f_bsize: ::c_ulong,
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/musl/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,6 @@ s! {
__f_spare: [::c_int; 6],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
#[doc(hidden)]
#[deprecated(
since = "0.2.54",
note = "Please leave a comment on \
https://github.com/rust-lang/libc/pull/1316 if you're using \
this field"
)]
pub _pad: [::c_int; 29],
_align: [u64; 0],
}

pub struct stack_t {
pub ss_sp: *mut ::c_void,
pub ss_flags: ::c_int,
Expand Down
8 changes: 0 additions & 8 deletions src/unix/linux_like/linux/musl/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ s! {
pub f_spare: [::c_ulong; 4],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
pub _pad: [::c_int; 29],
_align: [usize; 0],
}

pub struct statfs64 {
pub f_type: ::c_ulong,
pub f_bsize: ::c_ulong,
Expand Down
8 changes: 0 additions & 8 deletions src/unix/linux_like/linux/musl/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ s! {
pub struct sem_t {
__val: [::c_int; 8],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
pub _pad: [::c_int; 29],
_align: [usize; 0],
}
}

pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/musl/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,6 @@ s! {
pub __f_spare: [::c_int; 6],
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
#[doc(hidden)]
#[deprecated(
since = "0.2.54",
note = "Please leave a comment on \
https://github.com/rust-lang/libc/pull/1316 if you're using \
this field"
)]
pub _pad: [::c_int; 29],
_align: [u64; 0],
}

pub struct stack_t {
pub ss_sp: *mut ::c_void,
pub ss_flags: ::c_int,
Expand Down
20 changes: 20 additions & 0 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ s! {
pub sa_restorer: ::Option<extern "C" fn()>,
}

// `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is
// target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2)
pub struct siginfo_t {
pub si_signo: ::c_int,
#[cfg(not(target_arch = "mips"))]
pub si_errno: ::c_int,
pub si_code: ::c_int,
#[cfg(target_arch = "mips")]
pub si_errno: ::c_int,
#[doc(hidden)]
#[deprecated(
since = "0.2.54",
note = "Please leave a comment on \
https://github.com/rust-lang/libc/pull/1316 if you're using \
this field"
)]
pub _pad: [::c_int; 29],
_align: [usize; 0],
}

pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
Expand Down

0 comments on commit e1ff5d6

Please sign in to comment.