Skip to content

Commit 8189016

Browse files
bossmctgross35
authored andcommitted
musl: Unify definitions of siginfo_t
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 ] (backport <rust-lang#3261>) (cherry picked from commit e1ff5d6)
1 parent 036c68f commit 8189016

File tree

9 files changed

+20
-78
lines changed

9 files changed

+20
-78
lines changed

src/unix/linux_like/linux/musl/b32/arm/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ s! {
112112
pub f_spare: [::c_ulong; 4],
113113
}
114114

115-
pub struct siginfo_t {
116-
pub si_signo: ::c_int,
117-
pub si_errno: ::c_int,
118-
pub si_code: ::c_int,
119-
pub _pad: [::c_int; 29],
120-
_align: [usize; 0],
121-
}
122-
123115
pub struct statfs64 {
124116
pub f_type: ::c_ulong,
125117
pub f_bsize: ::c_ulong,

src/unix/linux_like/linux/musl/b32/hexagon.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ s! {
9090
pub f_spare: [::c_ulong; 4],
9191
}
9292

93-
pub struct siginfo_t {
94-
pub si_signo: ::c_int,
95-
pub si_errno: ::c_int,
96-
pub si_code: ::c_int,
97-
pub _pad: [::c_int; 29],
98-
_align: [usize; 0],
99-
}
100-
10193
pub struct statfs64 {
10294
pub f_type: ::c_ulong,
10395
pub f_bsize: ::c_ulong,

src/unix/linux_like/linux/musl/b32/mips/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ s! {
120120
pub f_spare: [::c_ulong; 5],
121121
}
122122

123-
pub struct siginfo_t {
124-
pub si_signo: ::c_int,
125-
pub si_code: ::c_int,
126-
pub si_errno: ::c_int,
127-
pub _pad: [::c_int; 29],
128-
_align: [usize; 0],
129-
}
130-
131123
pub struct statfs64 {
132124
pub f_type: ::c_ulong,
133125
pub f_bsize: ::c_ulong,

src/unix/linux_like/linux/musl/b32/powerpc.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ s! {
112112
pub f_spare: [::c_ulong; 4],
113113
}
114114

115-
pub struct siginfo_t {
116-
pub si_signo: ::c_int,
117-
pub si_errno: ::c_int,
118-
pub si_code: ::c_int,
119-
pub _pad: [::c_int; 29],
120-
_align: [usize; 0],
121-
}
122-
123115
pub struct statfs64 {
124116
pub f_type: ::c_ulong,
125117
pub f_bsize: ::c_ulong,

src/unix/linux_like/linux/musl/b32/riscv32/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,6 @@ s! {
113113
__f_spare: [::c_int; 6],
114114
}
115115

116-
pub struct siginfo_t {
117-
pub si_signo: ::c_int,
118-
pub si_errno: ::c_int,
119-
pub si_code: ::c_int,
120-
#[doc(hidden)]
121-
#[deprecated(
122-
since = "0.2.54",
123-
note = "Please leave a comment on \
124-
https://github.com/rust-lang/libc/pull/1316 if you're using \
125-
this field"
126-
)]
127-
pub _pad: [::c_int; 29],
128-
_align: [u64; 0],
129-
}
130-
131116
pub struct stack_t {
132117
pub ss_sp: *mut ::c_void,
133118
pub ss_flags: ::c_int,

src/unix/linux_like/linux/musl/b32/x86/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ s! {
116116
pub f_spare: [::c_ulong; 4],
117117
}
118118

119-
pub struct siginfo_t {
120-
pub si_signo: ::c_int,
121-
pub si_errno: ::c_int,
122-
pub si_code: ::c_int,
123-
pub _pad: [::c_int; 29],
124-
_align: [usize; 0],
125-
}
126-
127119
pub struct statfs64 {
128120
pub f_type: ::c_ulong,
129121
pub f_bsize: ::c_ulong,

src/unix/linux_like/linux/musl/b64/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ s! {
120120
pub struct sem_t {
121121
__val: [::c_int; 8],
122122
}
123-
124-
pub struct siginfo_t {
125-
pub si_signo: ::c_int,
126-
pub si_errno: ::c_int,
127-
pub si_code: ::c_int,
128-
pub _pad: [::c_int; 29],
129-
_align: [usize; 0],
130-
}
131123
}
132124

133125
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;

src/unix/linux_like/linux/musl/b64/riscv64/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,6 @@ s! {
119119
pub __f_spare: [::c_int; 6],
120120
}
121121

122-
pub struct siginfo_t {
123-
pub si_signo: ::c_int,
124-
pub si_errno: ::c_int,
125-
pub si_code: ::c_int,
126-
#[doc(hidden)]
127-
#[deprecated(
128-
since = "0.2.54",
129-
note = "Please leave a comment on \
130-
https://github.com/rust-lang/libc/pull/1316 if you're using \
131-
this field"
132-
)]
133-
pub _pad: [::c_int; 29],
134-
_align: [u64; 0],
135-
}
136-
137122
pub struct stack_t {
138123
pub ss_sp: *mut ::c_void,
139124
pub ss_flags: ::c_int,

src/unix/linux_like/linux/musl/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ s! {
144144
pub sa_restorer: ::Option<extern "C" fn()>,
145145
}
146146

147+
// `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is
148+
// target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2)
149+
pub struct siginfo_t {
150+
pub si_signo: ::c_int,
151+
#[cfg(not(target_arch = "mips"))]
152+
pub si_errno: ::c_int,
153+
pub si_code: ::c_int,
154+
#[cfg(target_arch = "mips")]
155+
pub si_errno: ::c_int,
156+
#[doc(hidden)]
157+
#[deprecated(
158+
since = "0.2.54",
159+
note = "Please leave a comment on \
160+
https://github.com/rust-lang/libc/pull/1316 if you're using \
161+
this field"
162+
)]
163+
pub _pad: [::c_int; 29],
164+
_align: [usize; 0],
165+
}
166+
147167
pub struct statvfs {
148168
pub f_bsize: ::c_ulong,
149169
pub f_frsize: ::c_ulong,

0 commit comments

Comments
 (0)