]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: add a size check to format timex members properly
authorMike Gilbert <floppym@gentoo.org>
Mon, 20 Dec 2021 00:39:37 +0000 (19:39 -0500)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 Dec 2021 03:36:59 +0000 (12:36 +0900)
As of glibc-2.34, the size of members in struct timex varies depending on
the _TIME_BITS macro.

Fixes: https://github.com/systemd/systemd/issues/21826
meson.build
src/basic/format-util.h

index 0e8f58eb2466c85d854f7f9ee17f1209eaa99a09..ff3e066e2cad93895a071d3c48ad22fb2c8b55eb 100644 (file)
@@ -468,6 +468,7 @@ conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
+conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('((struct timex *)0)->freq', prefix : '#include <sys/timex.h>'))
 
 decl_headers = '''
 #include <uchar.h>
index 7dd422b9874ca6b67f06a5d9981d120f50a11042..8719df3e299c4b681fa306427c01cc2bd904ed53 100644 (file)
@@ -26,10 +26,12 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
 #  error Unknown time_t size
 #endif
 
-#if defined __x86_64__ && defined __ILP32__
+#if SIZEOF_TIMEX_MEMBER == 8
 #  define PRI_TIMEX PRIi64
-#else
+#elif SIZEOF_TIMEX_MEMBER == 4
 #  define PRI_TIMEX "li"
+#else
+#  error Unknown timex member size
 #endif
 
 #if SIZEOF_RLIM_T == 8