]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
m4: Add option for 64-bit time_t on 32-bit systems with glibc-2.34 10933/head
authorSven Wegener <sven.wegener@stealer.net>
Sun, 31 Oct 2021 19:21:29 +0000 (20:21 +0100)
committerSven Wegener <sven.wegener@stealer.net>
Wed, 21 Feb 2024 21:50:26 +0000 (22:50 +0100)
glibc-2.34 includes the user-facing part of the 64-bit time_t support
for 32-bit systems. We treat this feature as experimental, as it causes
ABI issues, if 64-bit time_t values are passed to libraries that are
build with 32-bit time_t. It is safe for local use of 64-bit time_t.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
m4/pdns_check_time_t.m4

index c3d274b7e61b5b7a464286b8ee1802b6110266bc..9a9a2d5eb9a7564cfeff21e2d970b79de1467052 100644 (file)
@@ -1,4 +1,23 @@
 AC_DEFUN([PDNS_CHECK_TIME_T], [
+AC_ARG_ENABLE([experimental_64bit_time_t_support_on_glibc],
+  AS_HELP_STRING([--enable-experimental-64bit-time_t-support-on-glibc],
+    [enable experimental 64bit time_t support on >=glibc-2.34 for 32bit systems @<:@default=no@:>@]
+  ),
+  [enable_experimental_64bit_time_t_support_on_glibc=$enableval],
+  [enable_experimental_64bit_time_t_support_on_glibc=no]
+)
+AS_IF([test "x$enable_experimental_64bit_time_t_support_on_glibc" != "xno"],
+  # _TIME_BITS=64 is supported on glibc-2.34 and requires _FILE_OFFSET_BITS=64
+  [AC_EGREP_CPP(yes, [
+    #include <features.h>
+    #if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 34 || __GLIBC__ > 2
+      yes
+    #endif
+    ], [
+    CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
+    CXXFLAGS="${CXXFLAGS} -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
+  ])]
+)
 AX_COMPILE_CHECK_SIZEOF(time_t)
 AS_IF([test $ac_size -lt 8], [AC_MSG_ERROR([size of time_t is $ac_size, which is not large enough to fix the y2k38 bug])])
 AX_CHECK_SIGN([time_t], [:], [AC_MSG_ERROR([time_t is unsigned, PowerDNS code relies on it being signed])], [