Skip to content

Commit 05d00f6

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.
1 parent dc20464 commit 05d00f6

File tree

50 files changed

+128
-132
lines changed

Some content is hidden

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

50 files changed

+128
-132
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! <https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h>
44
5-
#[cfg(target_arch = "arm")]
65
use crate::prelude::*;
76

87
s! {
@@ -19,7 +18,7 @@ s! {
1918
pub __sp: u64,
2019
pub __pc: u64,
2120
pub __cpsr: u32,
22-
pub __pad: u32,
21+
__pad: Padding<u32>,
2322
}
2423

2524
#[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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ s! {
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/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: 4 additions & 4 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))]

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
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ s! {
537537
pub t_pw: i16,
538538
pub t_sl: i16,
539539
pub t_sw: i16,
540-
pub t_pad: [u16; 3],
540+
t_pad: Padding<[u16; 3]>,
541541
}
542542

543543
pub struct sockstat {
@@ -1040,11 +1040,11 @@ s! {
10401040
#[cfg(any(freebsd15, freebsd14, freebsd13))]
10411041
pub tcpi_dupacks: u32,
10421042
#[cfg(any(freebsd14, freebsd13))]
1043-
pub __tcpi_pad: [u32; 10],
1043+
__tcpi_pad: Padding<[u32; 10]>,
10441044
#[cfg(freebsd15)]
1045-
pub __tcpi_pad: [u32; 14],
1045+
__tcpi_pad: Padding<[u32; 14]>,
10461046
#[cfg(not(any(freebsd15, freebsd14, freebsd13)))]
1047-
pub __tcpi_pad: [u32; 26],
1047+
__tcpi_pad: Padding<[u32; 26]>,
10481048
}
10491049

10501050
pub struct _umtx_time {
@@ -1112,7 +1112,7 @@ s! {
11121112
pub sinfo_assoc_id: crate::sctp_assoc_t,
11131113
pub sinfo_keynumber: u16,
11141114
pub sinfo_keynumber_valid: u16,
1115-
pub __reserve_pad: [u8; SCTP_ALIGN_RESV_PAD],
1115+
__reserve_pad: Padding<[u8; SCTP_ALIGN_RESV_PAD]>,
11161116
}
11171117

11181118
pub struct sctp_extrcvinfo {
@@ -1132,7 +1132,7 @@ s! {
11321132
pub serinfo_next_ppid: u32,
11331133
pub sinfo_keynumber: u16,
11341134
pub sinfo_keynumber_valid: u16,
1135-
pub __reserve_pad: [u8; SCTP_ALIGN_RESV_PAD_SHORT],
1135+
__reserve_pad: Padding<[u8; SCTP_ALIGN_RESV_PAD_SHORT]>,
11361136
}
11371137

11381138
pub struct sctp_sndinfo {

0 commit comments

Comments
 (0)