Skip to content

Commit 60490f6

Browse files
committed
linux: Update the definition for ucontext_t and unskip its tests
The distributed versions of glibc now have the `__ssp` field, so we can add it here and start testing the type again. A field rename is needed since loongarch calls `__uc_flags` by a different name. (backport <#4760>) (cherry picked from commit f9f21cf)
1 parent 5bf0469 commit 60490f6

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

libc-test/build.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,7 +3995,7 @@ fn test_linux(target: &str) {
39953995
}
39963996
});
39973997

3998-
cfg.rename_struct_field(|struct_, field| {
3998+
cfg.rename_struct_field(move |struct_, field| {
39993999
let struct_ = struct_.ident();
40004000
match field.ident() {
40014001
// Our stat *_nsec fields normally don't actually exist but are part
@@ -4018,6 +4018,9 @@ fn test_linux(target: &str) {
40184018
Some("type".to_string())
40194019
}
40204020

4021+
// FIXME(1.0): field has a different name on loongarch
4022+
"uc_flags" if loongarch64 && struct_ == "ucontext_t" => Some("__uc_flags".to_string()),
4023+
40214024
_ => None,
40224025
}
40234026
});
@@ -4127,12 +4130,6 @@ fn test_linux(target: &str) {
41274130
// structs.
41284131
"termios2" => true,
41294132

4130-
// FIXME(linux): remove once we set minimum supported glibc version.
4131-
// ucontext_t added a new field as of glibc 2.28; our struct definition is
4132-
// conservative and omits the field, but that means the size doesn't match for newer
4133-
// glibcs (see https://github.com/rust-lang/libc/issues/1410)
4134-
"ucontext_t" if gnu => true,
4135-
41364133
// On Linux, the type of `ut_exit` field of struct `utmpx`
41374134
// can be an anonymous struct, so an extra struct,
41384135
// which is absent in musl, has to be defined.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,7 @@ s_no_extra_traits! {
310310
pub uc_mcontext: mcontext_t,
311311
pub uc_sigmask: crate::sigset_t,
312312
__private: [u8; 512],
313-
// FIXME(glibc): the shadow stack field requires glibc >= 2.28.
314-
// Re-add once we drop compatibility with glibc versions older than
315-
// 2.28.
316-
//
317-
// __ssp: [c_ulonglong; 4],
313+
__ssp: [c_ulonglong; 4],
318314
}
319315

320316
#[repr(align(16))]

0 commit comments

Comments
 (0)