From c7d713d8c391a4bf8d48d6ddea88074cd0826fbf Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 25 Nov 2024 10:41:03 -0700 Subject: [PATCH] Use SIGEV_PAD_SIZE in __c_anonymous_sigev_un on Linux --- src/unix/linux_like/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 37e441d85bb7..827b4842bd9b 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -269,10 +269,7 @@ s_no_extra_traits! { // Can't correctly impl Debug for unions #[allow(missing_debug_implementations)] pub union __c_anonymous_sigev_un { - #[cfg(target_pointer_width = "64")] - _pad: [::c_int; (64 - 2 * 4 - 8) / 4], - #[cfg(target_pointer_width = "32")] - _pad: [::c_int; (64 - 2 * 4 - 4) / 4], + _pad: [::c_int; SIGEV_PAD_SIZE], pub _tid: ::c_int, pub _sigev_thread: __c_anonymous_sigev_thread, } @@ -576,6 +573,13 @@ pub const SIGPIPE: ::c_int = 13; pub const SIGALRM: ::c_int = 14; pub const SIGTERM: ::c_int = 15; +const SIGEV_MAX_SIZE: usize = 64; +#[cfg(target_pointer_width = "64")] +const __ARCH_SIGEV_PREAMBLE_SIZE: usize = 4 * 2 + 8; +#[cfg(target_pointer_width = "32")] +const __ARCH_SIGEV_PREAMBLE_SIZE: usize = 4 * 2 + 4; +const SIGEV_PAD_SIZE: usize = (SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) / 4; + pub const PROT_NONE: ::c_int = 0; pub const PROT_READ: ::c_int = 1; pub const PROT_WRITE: ::c_int = 2;