From 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 22 Dec 2019 12:37:16 -0500 Subject: [PATCH] adjust utmpx struct layout for time64, 32-/64-bit arch compat since time64 switchover has changed the size and layout of the struct anyway, take the opportunity to fix it up so that it can be shared between 32- and 64-bit ABIs on the same system as long as byte order matches. the ut_type member is explicitly padded to make up for m68k having only 2-byte alignment; explicit padding has no effect on other archs. ut_session is changed from long to int, with endian-matched padding. this affects 64-bit archs as well, but brings the type into alignment with glibc's x86_64 struct, so it should not break software, and does not break on-disk format. the semantic type is int (pid-like) anyway. the padding produces correct alignment for the ut_tv member on 32-bit archs that don't naturally align it, so that ABI matches 64-bit. this type is presently not used anywhere in the ABI between libc and libc consumers; it's only used between pairs of consumers if a third-party utmp library using the system utmpx.h is in use. --- include/utmpx.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/utmpx.h b/include/utmpx.h index 0429014d..b293f427 100644 --- a/include/utmpx.h +++ b/include/utmpx.h @@ -16,6 +16,7 @@ extern "C" { struct utmpx { short ut_type; + short __ut_pad1; pid_t ut_pid; char ut_line[32]; char ut_id[4]; @@ -25,7 +26,11 @@ struct utmpx { short __e_termination; short __e_exit; } ut_exit; - long ut_session; +#if __BYTE_ORDER == 1234 + int ut_session, __ut_pad2; +#else + int __ut_pad2, ut_session; +#endif struct timeval ut_tv; unsigned ut_addr_v6[4]; char __unused[20]; -- 2.25.1