Skip to content

Commit 4dc6a1c

Browse files
committed
Revert "Remove array size hacks for Rust < 1.47"
This reverts commit 27ee6fe. These array structure changes were breaking changes to the public API and should not have landed without a major version bump.
1 parent 24a8e7e commit 4dc6a1c

File tree

15 files changed

+28
-15
lines changed

15 files changed

+28
-15
lines changed

libc-test/build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ fn test_apple(target: &str) {
400400
// FIXME: the array size has been changed since macOS 10.15 ([8] -> [7]).
401401
("statfs", "f_reserved") => true,
402402
("__darwin_arm_neon_state64", "__v") => true,
403-
403+
// MAXPATHLEN is too big for auto-derive traits on arrays.
404+
("vnode_info_path", "vip_path") => true,
404405
("ifreq", "ifr_ifru") => true,
405406
("in6_ifreq", "ifr_ifru") => true,
406407
("ifkpi", "ifk_data") => true,
@@ -2763,6 +2764,8 @@ fn test_freebsd(target: &str) {
27632764
("umutex", "m_owner") => true,
27642765
// c_has_waiters field is a volatile int32_t
27652766
("ucond", "c_has_waiters") => true,
2767+
// is PATH_MAX long but tests can't accept multi array as equivalent.
2768+
("kinfo_vmentry", "kve_path") => true,
27662769

27672770
// a_un field is a union
27682771
("Elf32_Auxinfo", "a_un") => true,
@@ -2791,6 +2794,10 @@ fn test_freebsd(target: &str) {
27912794
// Anonymous type.
27922795
("filestat", "next") => true,
27932796

2797+
// We ignore this field because we needed to use a hack in order to make rust 1.19
2798+
// happy...
2799+
("kinfo_proc", "ki_sparestrings") => true,
2800+
27942801
// `__sem_base` is a private struct field
27952802
("semid_ds", "__sem_base") => true,
27962803

src/unix/bsd/apple/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,9 @@ s! {
939939

940940
pub struct vnode_info_path {
941941
pub vip_vi: vnode_info,
942-
pub vip_path: [::c_char; ::MAXPATHLEN as usize],
942+
// Normally it's `vip_path: [::c_char; MAXPATHLEN]` but because libc supports an old rustc
943+
// version, we go around this limitation like this.
944+
pub vip_path: [[::c_char; 32]; 32],
943945
}
944946

945947
pub struct proc_vnodepathinfo {

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

Lines changed: 1 addition & 1 deletion
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; 256],
520+
pub mc_fpregs: [[::c_uint; 8]; 32],
521521
}
522522

523523
pub struct ucontext_t {

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

Lines changed: 1 addition & 1 deletion
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; 46],
169+
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
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

Lines changed: 1 addition & 1 deletion
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; 46],
176+
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ s! {
183183
/// More thread name.
184184
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
185185
/// Spare string space.
186-
pub ki_sparestrings: [::c_char; 46],
186+
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
187187
/// Spare room for growth.
188188
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
189189
/// Controlling tty dev.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ s! {
183183
/// More thread name.
184184
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
185185
/// Spare string space.
186-
pub ki_sparestrings: [::c_char; 46],
186+
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
187187
/// Spare room for growth.
188188
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
189189
/// Controlling tty dev.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ s! {
183183
/// More thread name.
184184
pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1],
185185
/// Spare string space.
186-
pub ki_sparestrings: [::c_char; 46],
186+
pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq
187187
/// Spare room for growth.
188188
pub ki_spareints: [::c_int; ::KI_NSPARE_INT],
189189
/// Controlling tty dev.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ s! {
457457
_kve_is_spare: [::c_int; 8],
458458
#[cfg(freebsd11)]
459459
_kve_is_spare: [::c_int; 12],
460-
pub kve_path: [::c_char; ::PATH_MAX as usize],
460+
pub kve_path: [[::c_char; 32]; 32],
461461
}
462462

463463
pub struct __c_anonymous_filestat {

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 1 addition & 1 deletion
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; 240],
287+
af_arg: [[::c_char; 10]; 24],
288288
}
289289

290290
pub struct ptrace_io_desc {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ s! {
671671
pub kve_vn_rdev: u64,
672672
pub kve_vn_type: u32,
673673
pub kve_vn_mode: u32,
674-
pub kve_path: [::c_char; ::PATH_MAX as usize],
674+
pub kve_path: [[::c_char; 32]; 32],
675675
}
676676

677677
pub struct __c_anonymous_posix_spawn_fae_open {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ s! {
7272
pub sp: ::c_ulonglong,
7373
pub pc: ::c_ulonglong,
7474
pub pstate: ::c_ulonglong,
75-
__reserved: [u64; 512],
75+
// nested arrays to get the right size/length while being able to
76+
// auto-derive traits like Debug
77+
__reserved: [[u64; 32]; 16],
7678
}
7779

7880
pub struct user_fpsimd_struct {

src/unix/linux_like/android/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ s_no_extra_traits! {
608608
pub struct prop_info {
609609
__name: [::c_char; 32],
610610
__serial: ::c_uint,
611-
__value: [::c_char; 92],
611+
__value: [[::c_char; 4]; 23],
612612
}
613613

614614
pub union __c_anonymous_ifr_ifru {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ s! {
212212
pub sp: ::c_ulonglong,
213213
pub pc: ::c_ulonglong,
214214
pub pstate: ::c_ulonglong,
215-
__reserved: [u64; 512],
215+
// nested arrays to get the right size/length while being able to
216+
// auto-derive traits like Debug
217+
__reserved: [[u64; 32]; 16],
216218
}
217219

218220
pub struct user_fpsimd_struct {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ s! {
8484
pub sp: ::c_ulong,
8585
pub pc: ::c_ulong,
8686
pub pstate: ::c_ulong,
87-
__reserved: [u64; 512],
87+
__reserved: [[u64; 32]; 16],
8888
}
8989

9090
#[repr(align(8))]

0 commit comments

Comments
 (0)