Skip to content

Commit c7d713d

Browse files
committed
Use SIGEV_PAD_SIZE in __c_anonymous_sigev_un on Linux
1 parent af57295 commit c7d713d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/unix/linux_like/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,7 @@ s_no_extra_traits! {
269269
// Can't correctly impl Debug for unions
270270
#[allow(missing_debug_implementations)]
271271
pub union __c_anonymous_sigev_un {
272-
#[cfg(target_pointer_width = "64")]
273-
_pad: [::c_int; (64 - 2 * 4 - 8) / 4],
274-
#[cfg(target_pointer_width = "32")]
275-
_pad: [::c_int; (64 - 2 * 4 - 4) / 4],
272+
_pad: [::c_int; SIGEV_PAD_SIZE],
276273
pub _tid: ::c_int,
277274
pub _sigev_thread: __c_anonymous_sigev_thread,
278275
}
@@ -576,6 +573,13 @@ pub const SIGPIPE: ::c_int = 13;
576573
pub const SIGALRM: ::c_int = 14;
577574
pub const SIGTERM: ::c_int = 15;
578575

576+
const SIGEV_MAX_SIZE: usize = 64;
577+
#[cfg(target_pointer_width = "64")]
578+
const __ARCH_SIGEV_PREAMBLE_SIZE: usize = 4 * 2 + 8;
579+
#[cfg(target_pointer_width = "32")]
580+
const __ARCH_SIGEV_PREAMBLE_SIZE: usize = 4 * 2 + 4;
581+
const SIGEV_PAD_SIZE: usize = (SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) / 4;
582+
579583
pub const PROT_NONE: ::c_int = 0;
580584
pub const PROT_READ: ::c_int = 1;
581585
pub const PROT_WRITE: ::c_int = 2;

0 commit comments

Comments
 (0)