From a82862040b9e85532eb0250f179469fa7cde63ed Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 15 Dec 2025 12:25:32 +0100 Subject: [PATCH 1/3] linux: Add missing padding in struct input_event for sparc64 --- src/unix/linux_like/linux/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e54dd5ef685b..ddbbf264e817 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -240,6 +240,8 @@ s! { #[cfg(all(target_pointer_width = "32", linux_time_bits64))] pub input_event_usec: c_ulong, + #[cfg(target_arch = "sparc64")] + _pad1: Padding, pub type_: __u16, pub code: __u16, pub value: __s32, From 0bc998ffc557516dc563fb28aba97f090019de18 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 15 Dec 2025 15:34:37 +0100 Subject: [PATCH 2/3] test: musl: Skip time64-dependent struct input_event This is intended to be removed together with the other things once the PR adding our version of `_REDIR_TIME64` lands. --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 25126877d450..726684ea17b0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4785,7 +4785,7 @@ fn test_linux(target: &str) { }); cfg.skip_struct(|s| match s.ident() { "utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "itimerspec" - | "timex" | "ntptimeval" | "stat" | "shmid_ds" | "msqid_ds" => true, + | "timex" | "ntptimeval" | "stat" | "shmid_ds" | "msqid_ds" | "input_event" => true, _ => false, }); From fc7a7cf10cc80712c902a6483b1f0403fcce2ded Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 17 Mar 2023 15:21:05 +0100 Subject: [PATCH 3/3] linux: Use the input_event_X macros to access input_event members This means the same members are available in the struct no matter whether it is a 32 or 64 bit platform or the linux_time_bits64 config is set. --- src/unix/linux_like/linux/mod.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index ddbbf264e817..4a77121d62e6 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -225,18 +225,17 @@ s! { } pub struct input_event { - // FIXME(1.0): Change to the commented variant, see https://github.com/rust-lang/libc/pull/4148#discussion_r1857511742 + // input_event_sec and input_event_usec are preprocessor macros in C. + // On all variants _except_ 32-bit long and 64-bit time_t they actually + // refer to members of input_event.time, a timeval struct. + // The timeval struct has two members of type time_t and suseconds_t. #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] - pub time: crate::timeval, - // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] - // pub input_event_sec: time_t, - // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] - // pub input_event_usec: suseconds_t, - // #[cfg(target_arch = "sparc64")] - // _pad1: c_int, + pub input_event_sec: crate::time_t, #[cfg(all(target_pointer_width = "32", linux_time_bits64))] pub input_event_sec: c_ulong, + #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] + pub input_event_usec: crate::suseconds_t, #[cfg(all(target_pointer_width = "32", linux_time_bits64))] pub input_event_usec: c_ulong,