From 9aa27561dcbe3b6f83c20f1650287769bc825bef Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 15 Dec 2025 12:25:32 +0100 Subject: [PATCH 1/2] 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 f277569e20453..b8dbfb1f3fe9d 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -239,6 +239,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 568a5319ee96a3ddb1850430ab65cb9ac1d0a975 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 17 Mar 2023 15:21:05 +0100 Subject: [PATCH 2/2] 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 b8dbfb1f3fe9d..2a8dcd1339da9 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -224,18 +224,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,