Skip to content

Commit 73a513e

Browse files
committed
cleanup: Declare more padding fields as private Padding's
We have more fields that are padding areas that are currently marked as public and not marked as Padding, which is causing the generated Hash and PartialEq implementations to take care of them wrongly. So fix them
1 parent ec63a9d commit 73a513e

File tree

52 files changed

+169
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+169
-172
lines changed

libc-test/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,9 +4597,6 @@ fn test_linux(target: &str) {
45974597
cfg.skip_struct_field(move |struct_, field| {
45984598
let struct_ = struct_.ident();
45994599
let field = field.ident();
4600-
// this is actually a union on linux, so we can't represent it well and
4601-
// just insert some padding.
4602-
(struct_ == "siginfo_t" && field == "_pad") ||
46034600
// musl names this __dummy1 but it's still there
46044601
(musl && struct_ == "glob_t" && field == "gl_flags") ||
46054602
// musl seems to define this as an *anonymous* bitfield
@@ -4630,7 +4627,7 @@ fn test_linux(target: &str) {
46304627
&& ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32)
46314628
) ||
46324629
// the `u` field is in fact an anonymous union
4633-
(gnu && struct_ == "ptrace_syscall_info" && (field == "u" || field == "pad")) ||
4630+
(gnu && struct_ == "ptrace_syscall_info" && (field == "u")) ||
46344631
// the vregs field is a `__uint128_t` C's type.
46354632
(struct_ == "user_fpsimd_struct" && field == "vregs") ||
46364633
// Linux >= 5.11 tweaked the `svm_zero` field of the `sockaddr_vm` struct.

src/fuchsia/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ s! {
520520
pub ssi_syscall: i32,
521521
pub ssi_call_addr: u64,
522522
pub ssi_arch: u32,
523-
_pad: [u8; 28],
523+
_pad: Padding<[u8; 28]>,
524524
}
525525

526526
pub struct itimerspec {
@@ -820,7 +820,7 @@ s! {
820820

821821
pub struct cmsghdr {
822822
pub cmsg_len: crate::socklen_t,
823-
pub __pad1: c_int,
823+
__pad1: Padding<c_int>,
824824
pub cmsg_level: c_int,
825825
pub cmsg_type: c_int,
826826
}
@@ -833,7 +833,7 @@ s! {
833833
pub si_signo: c_int,
834834
pub si_errno: c_int,
835835
pub si_code: c_int,
836-
pub _pad: [c_int; 29],
836+
_pad: Padding<[c_int; 29]>,
837837
_align: [usize; 0],
838838
}
839839

@@ -886,7 +886,7 @@ s! {
886886
pub totalswap: c_ulong,
887887
pub freeswap: c_ulong,
888888
pub procs: c_ushort,
889-
pub pad: c_ushort,
889+
pad: Padding<c_ushort>,
890890
pub totalhigh: c_ulong,
891891
pub freehigh: c_ulong,
892892
pub mem_unit: c_uint,
@@ -970,7 +970,7 @@ s! {
970970
pub sigev_notify: c_int,
971971
pub sigev_notify_function: fn(crate::sigval),
972972
pub sigev_notify_attributes: *mut pthread_attr_t,
973-
pub __pad: [c_char; 56 - 3 * 8],
973+
__pad: Padding<[c_char; 56 - 3 * 8]>,
974974
}
975975

976976
#[cfg_attr(

src/new/apple/xnu/mach/arm/_structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ s! {
1919
pub __sp: u64,
2020
pub __pc: u64,
2121
pub __cpsr: u32,
22-
pub __pad: u32,
22+
__pad: Padding<u32>,
2323
}
2424

2525
#[cfg(target_arch = "aarch64")]

src/new/glibc/sysdeps/unix/linux/net/route.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ use crate::prelude::*;
77

88
s! {
99
pub struct rtentry {
10-
pub rt_pad1: c_ulong,
10+
rt_pad1: Padding<c_ulong>,
1111
pub rt_dst: crate::sockaddr,
1212
pub rt_gateway: crate::sockaddr,
1313
pub rt_genmask: crate::sockaddr,
1414
pub rt_flags: c_ushort,
15-
pub rt_pad2: c_short,
16-
pub rt_pad3: c_ulong,
15+
rt_pad2: Padding<c_short>,
16+
rt_pad3: Padding<c_ulong>,
1717
pub rt_tos: c_uchar,
1818
pub rt_class: c_uchar,
1919
// FIXME(1.0): private padding fields
2020
#[cfg(target_pointer_width = "64")]
21-
pub rt_pad4: [c_short; 3usize],
21+
rt_pad4: Padding<[c_short; 3usize]>,
2222
#[cfg(not(target_pointer_width = "64"))]
23-
pub rt_pad4: c_short,
23+
rt_pad4: Padding<c_short>,
2424
pub rt_metric: c_short,
2525
pub rt_dev: *mut c_char,
2626
pub rt_mtu: c_ulong,

src/new/musl/sys/socket.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ s! {
1010
pub msg_namelen: crate::socklen_t,
1111
pub msg_iov: *mut crate::iovec,
1212
#[cfg(all(target_pointer_width = "64", target_endian = "big"))]
13-
__pad1: c_int,
13+
__pad1: Padding<c_int>,
1414
pub msg_iovlen: c_int,
1515
#[cfg(all(target_pointer_width = "64", target_endian = "little"))]
16-
__pad1: c_int,
16+
__pad1: Padding<c_int>,
1717
pub msg_control: *mut c_void,
1818
#[cfg(all(target_pointer_width = "64", target_endian = "big"))]
19-
__pad2: c_int,
19+
__pad2: Padding<c_int>,
2020
pub msg_controllen: crate::socklen_t,
2121
#[cfg(all(target_pointer_width = "64", target_endian = "little"))]
22-
__pad2: c_int,
22+
__pad2: Padding<c_int>,
2323
pub msg_flags: c_int,
2424
}
2525

2626
pub struct cmsghdr {
2727
#[cfg(all(target_pointer_width = "64", target_endian = "big"))]
28-
pub __pad1: c_int,
28+
__pad1: Padding<c_int>,
2929
pub cmsg_len: crate::socklen_t,
3030
#[cfg(all(target_pointer_width = "64", target_endian = "little"))]
31-
pub __pad1: c_int,
31+
__pad1: Padding<c_int>,
3232
pub cmsg_level: c_int,
3333
pub cmsg_type: c_int,
3434
}

src/new/netbsd/utmpx_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ s! {
4646
pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported
4747
pub ut_ss: crate::sockaddr_storage,
4848
pub ut_tv: crate::timeval,
49-
ut_pad: [u8; _UTX_PADSIZE],
49+
ut_pad: Padding<[u8; _UTX_PADSIZE]>,
5050
}
5151

5252
pub struct __exit_status {

src/unix/aix/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ s! {
375375
pub ss_sp: *mut c_void,
376376
pub ss_size: size_t,
377377
pub ss_flags: c_int,
378-
pub __pad: [c_int; 4],
378+
__pad: Padding<[c_int; 4]>,
379379
}
380380

381381
pub struct posix_spawnattr_t {
@@ -422,7 +422,7 @@ s! {
422422
pub ut_time: time64_t,
423423
pub ut_exit: exit_status,
424424
pub ut_host: [c_char; 256],
425-
pub __dbl_word_pad: c_int,
425+
__dbl_word_pad: Padding<c_int>,
426426
pub __reservedA: [c_int; 2],
427427
pub __reservedV: [c_int; 6],
428428
}

src/unix/aix/powerpc64.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ s! {
127127

128128
pub struct __vmx_context_t {
129129
pub __vr: [crate::__vmxreg_t; 32],
130-
pub __pad1: [c_uint; 3],
130+
__pad1: Padding<[c_uint; 3]>,
131131
pub __vscr: c_uint,
132132
pub __vrsave: c_uint,
133-
pub __pad2: [c_uint; 3],
133+
__pad2: Padding<[c_uint; 3]>,
134134
}
135135

136136
pub struct __vsx_context_t {
@@ -158,7 +158,7 @@ s! {
158158
pub tmcontext: c_char,
159159
pub tmstate: c_char,
160160
pub prevowner: c_char,
161-
pub pad: [c_char; 5],
161+
pad: Padding<[c_char; 5]>,
162162
}
163163

164164
pub struct __context64 {
@@ -176,7 +176,7 @@ s! {
176176
pub fpeu: c_char,
177177
pub fpinfo: c_char,
178178
pub fpscr24_31: c_char,
179-
pub pad: [c_char; 1],
179+
pad: Padding<[c_char; 1]>,
180180
pub excp_type: c_int,
181181
}
182182

@@ -204,7 +204,7 @@ s! {
204204
pub uc_stack: crate::stack_t,
205205
pub __extctx: *mut crate::__extctx_t,
206206
pub __extctx_magic: c_int,
207-
pub __pad: [c_int; 1],
207+
__pad: Padding<[c_int; 1]>,
208208
}
209209

210210
pub struct utmpx {
@@ -215,7 +215,7 @@ s! {
215215
pub ut_type: c_short,
216216
pub ut_tv: crate::timeval,
217217
pub ut_host: [c_char; 256],
218-
pub __dbl_word_pad: c_int,
218+
__dbl_word_pad: Padding<c_int>,
219219
pub __reservedA: [c_int; 2],
220220
pub __reservedV: [c_int; 6],
221221
}
@@ -256,7 +256,7 @@ s! {
256256
pub si_band: c_long,
257257
pub si_value: crate::sigval,
258258
pub __si_flags: c_int,
259-
pub __pad: [c_int; 3],
259+
__pad: Padding<[c_int; 3]>,
260260
}
261261

262262
pub struct pollfd_ext {

src/unix/bsd/apple/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ s! {
845845
pub struct vnode_info {
846846
pub vi_stat: vinfo_stat,
847847
pub vi_type: c_int,
848-
pub vi_pad: c_int,
848+
vi_pad: Padding<c_int>,
849849
pub vi_fsid: crate::fsid_t,
850850
}
851851

@@ -1234,10 +1234,10 @@ s! {
12341234
pub sem_base: i32,
12351235
pub sem_nsems: c_ushort,
12361236
pub sem_otime: crate::time_t,
1237-
pub sem_pad1: i32,
1237+
sem_pad1: Padding<i32>,
12381238
pub sem_ctime: crate::time_t,
1239-
pub sem_pad2: i32,
1240-
pub sem_pad3: [i32; 4],
1239+
sem_pad2: Padding<i32>,
1240+
sem_pad3: Padding<[i32; 4]>,
12411241
}
12421242

12431243
#[repr(packed(4))]
@@ -1313,7 +1313,7 @@ s! {
13131313
pub ut_type: c_short,
13141314
pub ut_tv: crate::timeval,
13151315
pub ut_host: [c_char; _UTX_HOSTSIZE],
1316-
ut_pad: [u32; 16],
1316+
ut_pad: Padding<[u32; 16]>,
13171317
}
13181318

13191319
pub struct sigevent {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ s! {
1313
pub gp_sp: crate::register_t,
1414
pub gp_elr: crate::register_t,
1515
pub gp_spsr: u32,
16-
pub gp_pad: c_int,
16+
gp_pad: Padding<c_int>,
1717
}
1818

1919
pub struct fpregs {
2020
pub fp_q: u128,
2121
pub fp_sr: u32,
2222
pub fp_cr: u32,
2323
pub fp_flags: c_int,
24-
pub fp_pad: c_int,
24+
fp_pad: Padding<c_int>,
2525
}
2626

2727
pub struct mcontext_t {
2828
pub mc_gpregs: gpregs,
2929
pub mc_fpregs: fpregs,
3030
pub mc_flags: c_int,
31-
pub mc_pad: c_int,
31+
mc_pad: Padding<c_int>,
3232
pub mc_spare: [u64; 8],
3333
}
3434
}

0 commit comments

Comments
 (0)