Skip to content

Commit 3154cac

Browse files
committed
Remove array size hacks for Rust < 1.47
Rust >= 1.47 supports traits for arrays of arbitrary size, so remove the various hacks using nested arrays when the native platform definition uses a single array.
1 parent c7bc6a8 commit 3154cac

File tree

14 files changed

+14
-29
lines changed

14 files changed

+14
-29
lines changed

libc-test/build.rs

-8
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,6 @@ fn test_apple(target: &str) {
322322
// FIXME: the array size has been changed since macOS 10.15 ([8] -> [7]).
323323
("statfs", "f_reserved") => true,
324324
("__darwin_arm_neon_state64", "__v") => true,
325-
// MAXPATHLEN is too big for auto-derive traits on arrays.
326-
("vnode_info_path", "vip_path") => true,
327325
_ => false,
328326
}
329327
});
@@ -2242,8 +2240,6 @@ fn test_freebsd(target: &str) {
22422240
("umutex", "m_owner") => true,
22432241
// c_has_waiters field is a volatile int32_t
22442242
("ucond", "c_has_waiters") => true,
2245-
// is PATH_MAX long but tests can't accept multi array as equivalent.
2246-
("kinfo_vmentry", "kve_path") => true,
22472243

22482244
// a_un field is a union
22492245
("Elf32_Auxinfo", "a_un") => true,
@@ -2272,10 +2268,6 @@ fn test_freebsd(target: &str) {
22722268
// Anonymous type.
22732269
("filestat", "next") => true,
22742270

2275-
// We ignore this field because we needed to use a hack in order to make rust 1.19
2276-
// happy...
2277-
("kinfo_proc", "ki_sparestrings") => true,
2278-
22792271
// `__sem_base` is a private struct field
22802272
("semid_ds", "__sem_base") => true,
22812273

src/unix/bsd/apple/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,7 @@ s! {
818818

819819
pub struct vnode_info_path {
820820
pub vip_vi: vnode_info,
821-
// Normally it's `vip_path: [::c_char; MAXPATHLEN]` but because libc supports an old rustc
822-
// version, we go around this limitation like this.
823-
pub vip_path: [[::c_char; 32]; 32],
821+
pub vip_path: [::c_char; ::MAXPATHLEN as usize],
824822
}
825823

826824
pub struct proc_vnodepathinfo {

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ s_no_extra_traits! {
517517
pub mc_ownedfp: ::c_uint,
518518
__reserved: ::c_uint,
519519
__unused: [::c_uint; 8],
520-
pub mc_fpregs: [[::c_uint; 8]; 32],
520+
pub mc_fpregs: [::c_uint; 256],
521521
}
522522

523523
pub struct ucontext_t {
@@ -786,8 +786,7 @@ cfg_if! {
786786
self.mc_len == other.mc_len &&
787787
self.mc_fpformat == other.mc_fpformat &&
788788
self.mc_ownedfp == other.mc_ownedfp &&
789-
self.mc_fpregs.iter().zip(other.mc_fpregs.iter()).
790-
all(|(a, b)| a == b)
789+
self.mc_fpregs == other.mc_fpregs
791790
}
792791
}
793792
impl Eq for mcontext_t {}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ s! {
166166
/// More thread name.
167167
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
168168
/// Spare string space.
169-
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
169+
pub ki_sparestrings: [::c_char; 46],
170170
/// Spare room for growth.
171171
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
172172
/// Which cpu we are on.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ s! {
173173
/// More thread name.
174174
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
175175
/// Spare string space.
176-
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
176+
pub ki_sparestrings: [::c_char; 46],
177177
/// Spare room for growth.
178178
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
179179
/// Controlling tty dev.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ s! {
180180
/// More thread name.
181181
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
182182
/// Spare string space.
183-
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
183+
pub ki_sparestrings: [::c_char; 46],
184184
/// Spare room for growth.
185185
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
186186
/// Controlling tty dev.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ s! {
180180
/// More thread name.
181181
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
182182
/// Spare string space.
183-
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
183+
pub ki_sparestrings: [::c_char; 46],
184184
/// Spare room for growth.
185185
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
186186
/// Controlling tty dev.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ s! {
442442
_kve_is_spare: [::c_int; 8],
443443
#[cfg(freebsd11)]
444444
_kve_is_spare: [::c_int; 12],
445-
pub kve_path: [[::c_char; 32]; 32],
445+
pub kve_path: [::c_char; ::PATH_MAX as usize],
446446
}
447447

448448
pub struct __c_anonymous_filestat {

src/unix/bsd/freebsdlike/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ s! {
284284

285285
pub struct accept_filter_arg {
286286
pub af_name: [::c_char; 16],
287-
af_arg: [[::c_char; 10]; 24],
287+
af_arg: [::c_char; 240],
288288
}
289289

290290
pub struct ptrace_io_desc {

src/unix/bsd/netbsdlike/netbsd/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ s! {
635635
pub kve_vn_rdev: u64,
636636
pub kve_vn_type: u32,
637637
pub kve_vn_mode: u32,
638-
pub kve_path: [[::c_char; 32]; 32],
638+
pub kve_path: [::c_char; ::PATH_MAX as usize],
639639
}
640640

641641
pub struct __c_anonymous_posix_spawn_fae_open {

src/unix/linux_like/android/b64/aarch64/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ s! {
7171
pub sp: ::c_ulonglong,
7272
pub pc: ::c_ulonglong,
7373
pub pstate: ::c_ulonglong,
74-
// nested arrays to get the right size/length while being able to
75-
// auto-derive traits like Debug
76-
__reserved: [[u64; 32]; 16],
74+
__reserved: [u64; 512],
7775
}
7876

7977
pub struct user_fpsimd_struct {

src/unix/linux_like/android/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ s_no_extra_traits! {
432432
pub struct prop_info {
433433
__name: [::c_char; 32],
434434
__serial: ::c_uint,
435-
__value: [[::c_char; 4]; 23],
435+
__value: [::c_char; 92],
436436
}
437437
}
438438

src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ s! {
218218
pub sp: ::c_ulonglong,
219219
pub pc: ::c_ulonglong,
220220
pub pstate: ::c_ulonglong,
221-
// nested arrays to get the right size/length while being able to
222-
// auto-derive traits like Debug
223-
__reserved: [[u64; 32]; 16],
221+
__reserved: [u64; 512],
224222
}
225223

226224
pub struct user_fpsimd_struct {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ s! {
8383
pub sp: ::c_ulong,
8484
pub pc: ::c_ulong,
8585
pub pstate: ::c_ulong,
86-
__reserved: [[u64; 32]; 16],
86+
__reserved: [u64; 512],
8787
}
8888

8989
#[repr(align(8))]

0 commit comments

Comments
 (0)