Skip to content

Commit 60c9510

Browse files
joshtripletttgross35
authored andcommitted
Require rust >= 1.26 and drop libc_int128 conditional
[ resolve conflicts and add test skips that seem to be needed now - Trevor ] (apply <rust-lang#4060> to `main`) (cherry picked from commit 23a0d01)
1 parent 30809c5 commit 60c9510

File tree

9 files changed

+58
-76
lines changed

9 files changed

+58
-76
lines changed

libc-test/build.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ fn test_apple(target: &str) {
318318
// FIXME: Requires the macOS 14.4 SDK.
319319
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true,
320320

321+
// FIXME: "'__uint128' undeclared" in C
322+
"__uint128" => true,
323+
321324
_ => false,
322325
}
323326
});
@@ -1798,12 +1801,13 @@ fn test_android(target: &str) {
17981801
// These are tested in the `linux_elf.rs` file.
17991802
"Elf64_Phdr" | "Elf32_Phdr" => true,
18001803

1801-
// FIXME: Somehow fails to test after removing cfg hacks:
1802-
"__uint128" => true,
1803-
18041804
// These are intended to be opaque
18051805
"posix_spawn_file_actions_t" => true,
18061806
"posix_spawnattr_t" => true,
1807+
1808+
// FIXME: "'__uint128' undeclared" in C
1809+
"__uint128" => true,
1810+
18071811
_ => false,
18081812
}
18091813
});
@@ -3659,7 +3663,7 @@ fn test_linux(target: &str) {
36593663
"priority_t" if musl => true,
36603664
"name_t" if musl => true,
36613665

3662-
// FIXME: Somehow fails to test after removing cfg hacks:
3666+
// FIXME: "'__uint128' undeclared" in C
36633667
"__uint128" => true,
36643668

36653669
t => {

src/fixed_width_ints.rs

+32-34
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub type uint32_t = u32;
2020
pub type uint64_t = u64;
2121

2222
cfg_if! {
23-
if #[cfg(all(target_arch = "aarch64", not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))))] {
23+
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
2424
// This introduces partial support for FFI with __int128 and
2525
// equivalent types on platforms where Rust's definition is validated
2626
// to match the standard C ABI of that platform.
@@ -59,43 +59,41 @@ cfg_if! {
5959
/// C __uint128_t (alternate name for [__uint128][])
6060
pub type __uint128_t = u128;
6161

62-
macro_rules! static_assert_eq {
63-
($a:expr, $b:expr) => {
64-
const _: [(); $a] = [(); $b];
65-
};
66-
}
62+
cfg_if! {
63+
if #[cfg(libc_underscore_const_names)] {
64+
macro_rules! static_assert_eq {
65+
($a:expr, $b:expr) => {
66+
const _: [(); $a] = [(); $b];
67+
};
68+
}
6769

68-
// NOTE: if you add more platforms to here, you may need to cfg
69-
// these consts. They should always match the platform's values
70-
// for `sizeof(__int128)` and `_Alignof(__int128)`.
71-
const _SIZE_128: usize = 16;
72-
const _ALIGN_128: usize = 16;
70+
// NOTE: if you add more platforms to here, you may need to cfg
71+
// these consts. They should always match the platform's values
72+
// for `sizeof(__int128)` and `_Alignof(__int128)`.
73+
const _SIZE_128: usize = 16;
74+
const _ALIGN_128: usize = 16;
7375

74-
// Since Rust doesn't officially guarantee that these types
75-
// have compatible ABIs, we const assert that these values have the
76-
// known size/align of the target platform's libc. If rustc ever
77-
// tries to regress things, it will cause a compilation error.
78-
//
79-
// This isn't a bullet-proof solution because e.g. it doesn't
80-
// catch the fact that llvm and gcc disagree on how x64 __int128
81-
// is actually *passed* on the stack (clang underaligns it for
82-
// the same reason that rustc *never* properly aligns it).
83-
// FIXME: temporarily disabled because of a ctest2 bug.
84-
// static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128);
85-
// static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128);
76+
// Since Rust doesn't officially guarantee that these types
77+
// have compatible ABIs, we const assert that these values have the
78+
// known size/align of the target platform's libc. If rustc ever
79+
// tries to regress things, it will cause a compilation error.
80+
//
81+
// This isn't a bullet-proof solution because e.g. it doesn't
82+
// catch the fact that llvm and gcc disagree on how x64 __int128
83+
// is actually *passed* on the stack (clang underaligns it for
84+
// the same reason that rustc *never* properly aligns it).
85+
static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128);
86+
static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128);
8687

87-
// static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128);
88-
// static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128);
88+
static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128);
89+
static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128);
8990

90-
// static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128);
91-
// static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128);
91+
static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128);
92+
static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128);
9293

93-
// static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
94-
// static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
95-
} else if #[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))] {
96-
/// /// C `__int128_t`
97-
pub type __int128_t = i128;
98-
/// /// C `__uint128_t`
99-
pub type __uint128_t = u128;
94+
static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
95+
static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
96+
}
97+
}
10098
}
10199
}

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

-7
This file was deleted.

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ s! {
7676
// auto-derive traits like Debug
7777
__reserved: [[u64; 32]; 16],
7878
}
79+
80+
pub struct user_fpsimd_struct {
81+
pub vregs: [::__uint128_t; 32],
82+
pub fpsr: u32,
83+
pub fpcr: u32,
84+
}
7985
}
8086

8187
s_no_extra_traits! {
@@ -466,6 +472,3 @@ pub const PROT_MTE: ::c_int = 0x20;
466472
// From NDK's asm/auxvec.h
467473
pub const AT_SYSINFO_EHDR: ::c_ulong = 33;
468474
pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2;
469-
470-
mod int128;
471-
pub use self::int128::*;

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

-8
This file was deleted.

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

-7
This file was deleted.

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ s! {
217217
__reserved: [[u64; 32]; 16],
218218
}
219219

220+
pub struct user_fpsimd_struct {
221+
pub vregs: [::__uint128_t; 32],
222+
pub fpsr: ::c_uint,
223+
pub fpcr: ::c_uint,
224+
}
225+
220226
#[repr(align(8))]
221227
pub struct clone_args {
222228
pub flags: ::c_ulonglong,
@@ -964,6 +970,3 @@ cfg_if! {
964970
pub use self::lp64::*;
965971
}
966972
}
967-
968-
mod int128;
969-
pub use self::int128::*;

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

-7
This file was deleted.

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ s! {
101101
pub set_tid_size: ::c_ulonglong,
102102
pub cgroup: ::c_ulonglong,
103103
}
104+
105+
pub struct user_fpsimd_struct {
106+
pub vregs: [::__uint128_t; 32],
107+
pub fpsr: u32,
108+
pub fpcr: u32,
109+
}
104110
}
105111

106112
s_no_extra_traits! {
@@ -686,6 +692,3 @@ pub const VMIN: usize = 6;
686692
pub const IEXTEN: ::tcflag_t = 0x00008000;
687693
pub const TOSTOP: ::tcflag_t = 0x00000100;
688694
pub const FLUSHO: ::tcflag_t = 0x00001000;
689-
690-
mod int128;
691-
pub use self::int128::*;

0 commit comments

Comments
 (0)