bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] largefile: sync from Autoconf master


From: Paul Eggert
Subject: [PATCH] largefile: sync from Autoconf master
Date: Sun, 25 Dec 2022 11:44:28 -0800

* m4/largefile.m4 (gl_SET_LARGEFILE_SOURCE): Test whether
AC_SYS_YEAR2038 is defined when this macro is defined, not when it
is used, as we now define AC_SYS_YEAR2038 later.
(_AC_SYS_LARGEFILE_MACRO_VALUE): Remove.
(_AC_SYS_YEAR2038_TEST_CODE, _AC_SYS_YEAR2038_OPTIONS)
(_AC_SYS_YEAR2038_PROBE, _AC_SYS_YEAR2038_ENABLE)
(_AC_SYS_YEAR2038_OPT_IN, AC_SYS_YEAR2038)
(_AC_SYS_LARGEFILE_TEST_CODE, _AC_SYS_LARGEFILE_OPTIONS)
(_AC_SYS_LARGEFILE_PROBE, _AC_SYS_LARGEFILE_ENABLE): New macros.
(AC_SYS_LARGEFILE): Use them.
* m4/year2038.m4: Remove.  All mentions removed.
* modules/largefile, modules/year2038 (configure.ac-early):
Do not require gl_YEAR2038_EARLY.
* modules/year2038 (Depends-on): Depend on largefile.
(configure.ac): Require AC_SYS_YEAR2038, not gl_YEAR2038.
---
 ChangeLog         |  19 +++
 NEWS              |   5 +
 m4/largefile.m4   | 327 ++++++++++++++++++++++++++++++++++++----------
 m4/year2038.m4    | 132 -------------------
 modules/largefile |   4 +-
 modules/year2038  |   9 +-
 6 files changed, 287 insertions(+), 209 deletions(-)
 delete mode 100644 m4/year2038.m4

diff --git a/ChangeLog b/ChangeLog
index 9299d982f6..8a8ef2c82e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2022-12-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+       largefile: sync from Autoconf master
+       * m4/largefile.m4 (gl_SET_LARGEFILE_SOURCE): Test whether
+       AC_SYS_YEAR2038 is defined when this macro is defined, not when it
+       is used, as we now define AC_SYS_YEAR2038 later.
+       (_AC_SYS_LARGEFILE_MACRO_VALUE): Remove.
+       (_AC_SYS_YEAR2038_TEST_CODE, _AC_SYS_YEAR2038_OPTIONS)
+       (_AC_SYS_YEAR2038_PROBE, _AC_SYS_YEAR2038_ENABLE)
+       (_AC_SYS_YEAR2038_OPT_IN, AC_SYS_YEAR2038)
+       (_AC_SYS_LARGEFILE_TEST_CODE, _AC_SYS_LARGEFILE_OPTIONS)
+       (_AC_SYS_LARGEFILE_PROBE, _AC_SYS_LARGEFILE_ENABLE): New macros.
+       (AC_SYS_LARGEFILE): Use them.
+       * m4/year2038.m4: Remove.  All mentions removed.
+       * modules/largefile, modules/year2038 (configure.ac-early):
+       Do not require gl_YEAR2038_EARLY.
+       * modules/year2038 (Depends-on): Depend on largefile.
+       (configure.ac): Require AC_SYS_YEAR2038, not gl_YEAR2038.
+
 2022-12-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        extensions: enable some C23 Annex F functions
diff --git a/NEWS b/NEWS
index dd2374c4fd..16eac4c7df 100644
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,11 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2022-12-25  largefile       configure no longer enables year-2038 support,
+                            unless you configure with --enable-year2038
+                            or use the year2038 module.  This temporary
+                            hack should go away before the year 2038.
+
 2022-12-24  stdnoreturn     This module is deprecated.  Use _Noreturn
                             or the noreturn module instead.
 
diff --git a/m4/largefile.m4 b/m4/largefile.m4
index ec9677c46d..42c2f9780c 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -12,8 +12,7 @@
 # and ftello in C++ mode as well.
 # Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038.
 AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
-[
- m4_ifndef([AC_SYS_YEAR2038], [
+ m4_ifndef([AC_SYS_YEAR2038], [[
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_FUNC_FSEEKO
   case "$host_os" in
@@ -22,11 +21,10 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
         [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
       ;;
   esac
- ])
-])
+ ]])
+)
 
-# Work around a problem in Autoconf through 2.71 on glibc 2.34+
-# with _TIME_BITS.  Also, work around a problem in autoconf <= 2.69:
+# Work around a problem in autoconf <= 2.69:
 # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
 # or configures them incorrectly in some cases.
 m4_version_prereq([2.70], [], [
@@ -46,34 +44,258 @@ m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
 ])
 ])# m4_version_prereq 2.70
 
+# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier.
+# This code is taken from Autoconf master.
 m4_ifndef([AC_SYS_YEAR2038], [
 
-# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
-#                               CACHE-VAR,
-#                               DESCRIPTION,
-#                               PROLOGUE, [FUNCTION-BODY])
-# --------------------------------------------------------
-m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
-[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
-[while :; do
-  m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
-    [AC_LANG_PROGRAM([$5], [$6])],
-    [$3=no; break])
-  m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
-    [AC_LANG_PROGRAM([#undef $1
-#define $1 $2
-$5], [$6])],
-    [$3=$2; break])
-  $3=unknown
-  break
-done])
-case $$3 in #(
-  no | unknown) ;;
-  *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
-esac
-rm -rf conftest*[]dnl
-])# _AC_SYS_LARGEFILE_MACRO_VALUE
+# _AC_SYS_YEAR2038_TEST_CODE
+# --------------------------
+# C code used to probe for time_t that can represent time points more
+# than 2**31 - 1 seconds after the epoch.  With the usual Unix epoch,
+# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian),
+# hence the name.
+AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE],
+[[
+  #include <time.h>
+  /* Check that time_t can represent 2**32 - 1 correctly.  */
+  #define LARGE_TIME_T \\
+    ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))
+  int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535
+                           && LARGE_TIME_T % 65537 == 0)
+                          ? 1 : -1];
+]])
+
+# _AC_SYS_YEAR2038_OPTIONS
+# ------------------------
+# List of known ways to enable support for large time_t.  If you change
+# this list you probably also need to change the AS_CASE at the end of
+# _AC_SYS_YEAR2038_PROBE.
+m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
+    ["none needed"]                   dnl 64-bit and newer 32-bit Unix
+    ["-D_TIME_BITS=64"]               dnl glibc 2.34 with some 32-bit ABIs
+    ["-D__MINGW_USE_VC2005_COMPAT"]   dnl 32-bit MinGW
+    ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"]
+                                      dnl 32-bit MinGW (misconfiguration)
+))
+
+# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED])
+# -----------------------------------------
+# Subroutine of AC_SYS_YEAR2038.  Probe for time_t that can represent
+# time points more than 2**31 - 1 seconds after the epoch (dates after
+# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
+# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to
+# "support not detected" if none of them worked.  Then, set compilation
+# options and #defines as necessary to enable large time_t support.
+#
+# Note that we do not test whether mktime, localtime, etc. handle
+# large values of time_t correctly, as that would require use of
+# AC_TRY_RUN.  Note also that some systems only support large time_t
+# together with large off_t.
+#
+# If support is not detected, the behavior depends on which of the
+# top-level AC_SYS_YEAR2038 macros was used (see below).
+#
+# If you change this macro you may also need to change
+# _AC_SYS_YEAR2038_OPTIONS.
+AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
+[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038],
+  [ac_cv_sys_year2038_opts],
+  [ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_opt_found=no
+  for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do
+    AS_IF([test x"$ac_opt" != x"none needed"],
+      [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])],
+      [ac_cv_sys_year2038_opts="$ac_opt"
+      ac_opt_found=yes])
+    test $ac_opt_found = no || break
+  done
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"])
+
+ac_have_year2038=yes
+AS_CASE([$ac_cv_sys_year2038_opts],
+  ["none needed"], [],
+  ["support not detected"],
+    [ac_have_year2038=no
+     AS_CASE([$enable_year2038],
+      [yes],
+        [# If we're not cross compiling and 'touch' works with a large
+        # timestamp, then we can presume the system supports wider time_t
+        # *somehow* and we just weren't able to detect it.  One common
+        # case that we deliberately *don't* probe for is a system that
+        # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
+        # wide time_t.  (It would be inappropriate for us to override an
+        # intentional use of -m32.)  Error out, demanding use of
+        # --disable-year2038 if this is intentional.
+        AS_IF([test $cross_compiling = no],
+          [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
+            [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
+              [*'Feb  7  2106'* | *'Feb  7 17:10'*],
+              [AC_MSG_FAILURE(m4_text_wrap(
+      [this system appears to support timestamps after January 2038,
+       but no mechanism for enabling wide 'time_t' was detected.
+       Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
+       To proceed with 32-bit time_t, configure with '--disable-year2038'.],
+      [], [], [55]))])])])])],
+
+  ["-D_TIME_BITS=64"],
+    [AC_DEFINE([_TIME_BITS], [64],
+      [Number of bits in time_t, on hosts where this is settable.])],
+
+  ["-D__MINGW_USE_VC2005_COMPAT=1"],
+    [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
+      [Define to 1 on platforms where this makes time_t a 64-bit type.])],
+
+  ["-U_USE_32_BIT_TIME_T"*],
+    [AC_MSG_FAILURE(m4_text_wrap(
+      [the 'time_t' type is currently forced to be 32-bit.
+       It will stop working after January 2038.
+       Remove _USE_32BIT_TIME_T from the compiler flags.],
+      [], [], [55]))],
+
+  [AC_MSG_ERROR(
+    [internal error: bad value for \$ac_cv_sys_year2038_opts])])
+])
+
+# _AC_SYS_YEAR2038_ENABLE
+# -----------------------
+# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
+# Depending on which of the YEAR2038 macros was used, add either an
+# --enable-year2038, or a --disable-year2038, or no option at all to
+# the configure script.  Note that this is expanded very late and
+# therefore there cannot be any code in the AC_ARG_ENABLE.  The
+# default value for enable_year2038 is emitted unconditionally
+# because the generated code always looks at this variable.
+m4_define([_AC_SYS_YEAR2038_ENABLE],
+[m4_divert_text([DEFAULTS],
+  m4_provide_if([AC_SYS_YEAR2038],
+    [enable_year2038=yes],
+    [enable_year2038=no]))]dnl
+[AC_ARG_ENABLE([year2038],
+  m4_provide_if([AC_SYS_YEAR2038],
+    [AS_HELP_STRING([--disable-year2038],
+      [do not support timestamps after 2038])],
+    [AS_HELP_STRING([--enable-year2038],
+      [support timestamps after 2038])]))])
+
+# _AC_SYS_YEAR2038_OPT_IN
+# -----------------------
+# If the --enable-year2038 option is given to configure, attempt to
+# detect and activate support for large time_t on 32-bit systems.
+# This macro is automatically invoked by AC_SYS_LARGEFILE when large
+# *file* support is detected.  It does not AC_REQUIRE AC_SYS_LARGEFILE
+# to avoid a dependency loop, and is therefore unsafe to expose as a
+# documented macro.
+AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
+  AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
+  AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
+])])
+
+# AC_SYS_YEAR2038
+# ---------------
+# Attempt to detect and activate support for large time_t.
+# On systems where time_t is not always 64 bits, this probe can be
+# skipped by passing the --disable-year2038 option to configure.
+AC_DEFUN([AC_SYS_YEAR2038],
+[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl
+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
+  AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
+  AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
+])])
+
+# _AC_SYS_LARGEFILE_TEST_CODE
+# ---------------------------
+# C code used to probe for large file support.
+m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
+[@%:@include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
+  int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
+                      && LARGE_OFF_T % 2147483647 == 1)
+                     ? 1 : -1]];[]dnl
+])
+
+# _AC_SYS_LARGEFILE_OPTIONS
+# -------------------------
+# List of known ways to enable support for large files.  If you change
+# this list you probably also need to change the AS_CASE at the end of
+# _AC_SYS_LARGEFILE_PROBE.
+m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
+    ["none needed"]                   dnl Most current systems
+    ["-D_FILE_OFFSET_BITS=64"]        dnl X/Open LFS spec
+    ["-D_LARGE_FILES=1"]              dnl AIX (which versions?)
+    ["-n32"]                          dnl Irix 6.2 w/ SGI compiler
+))
+
+# _AC_SYS_LARGEFILE_PROBE
+# -----------------------
+# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set
+# the cache variable ac_cv_sys_largefile_opts to one of the values in
+# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if
+# none of the options in that list worked.  Then, set compilation
+# options and #defines as necessary to enable large file support.
+#
+# If large file support is not detected, the behavior depends on which of
+# the top-level AC_SYS_LARGEFILE macros was used (see below).
+#
+# If you change this macro you may also need to change
+# _AC_SYS_LARGEFILE_OPTIONS.
+AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
+[AC_CACHE_CHECK([for $CC option to enable large file support],
+  [ac_cv_sys_largefile_opts],
+  [ac_save_CC="$CC"
+  ac_opt_found=no
+  for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
+    AS_IF([test x"$ac_opt" != x"none needed"],
+      [CC="$ac_save_CC $ac_opt"])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
+      [ac_cv_sys_largefile_opts="$ac_opt"
+      ac_opt_found=yes])
+    test $ac_opt_found = no || break
+  done
+  CC="$ac_save_CC"
+  test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
+
+ac_have_largefile=yes
+AS_CASE([$ac_cv_sys_largefile_opts],
+  ["none needed"], [],
+  ["support not detected"],
+    [ac_have_largefile=no],
+
+  ["-D_FILE_OFFSET_BITS=64"],
+    [AC_DEFINE([_FILE_OFFSET_BITS], [64],
+      [Number of bits in a file offset, on hosts where this is settable.])],
+
+  ["-D_LARGE_FILES=1"],
+    [AC_DEFINE([_LARGE_FILES], [1],
+      [Define to 1 on platforms where this makes off_t a 64-bit type.])],
+
+  ["-n32"],
+    [CC="$CC -n32"],
+
+  [AC_MSG_ERROR(
+    [internal error: bad value for \$ac_cv_sys_largefile_opts])])
+
+_AC_SYS_YEAR2038_OPT_IN
+])
 
+# _AC_SYS_LARGEFILE_ENABLE
+# ------------------------
+# Subroutine of AC_SYS_LARGEFILE.  Note that this
+# is expanded very late and therefore there cannot be any code in the
+# AC_ARG_ENABLE.  The default value for enable_largefile is emitted
+# unconditionally because the generated shell code always looks at
+# this variable.
+m4_define([_AC_SYS_LARGEFILE_ENABLE],
+[m4_divert_text([DEFAULTS],
+  enable_largefile=yes)]dnl
+[AC_ARG_ENABLE([largefile],
+  [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])
 
 # AC_SYS_LARGEFILE
 # ----------------
@@ -84,44 +306,13 @@ rm -rf conftest*[]dnl
 # Additionally, on Linux file systems with 64-bit inodes a file that happens
 # to have a 64-bit inode number cannot be accessed by 32-bit applications on
 # Linux x86/x86_64.  This can occur with file systems such as XFS and NFS.
+# This macro allows configuration to continue if the system doesn't support
+# large files.
 AC_DEFUN([AC_SYS_LARGEFILE],
-[AC_ARG_ENABLE(largefile,
-               [  --disable-largefile     omit support for large files])
-AS_IF([test "$enable_largefile" != no],
- [AC_CACHE_CHECK([for special C compiler options needed for large files],
-    ac_cv_sys_largefile_CC,
-    [ac_cv_sys_largefile_CC=no
-     if test "$GCC" != yes; then
-       ac_save_CC=$CC
-       while :; do
-         # IRIX 6.2 and later do not support large files by default,
-         # so use the C compiler's -n32 option if that helps.
-         AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
-         AC_COMPILE_IFELSE([], [break])
-         CC="$CC -n32"
-         AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
-         break
-       done
-       CC=$ac_save_CC
-       rm -f conftest.$ac_ext
-    fi])
-  if test "$ac_cv_sys_largefile_CC" != no; then
-    CC=$CC$ac_cv_sys_largefile_CC
-  fi
-
-  _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
-    ac_cv_sys_file_offset_bits,
-    [Number of bits in a file offset, on hosts where this is settable.],
-    [_AC_SYS_LARGEFILE_TEST_INCLUDES])
-  AS_CASE([$ac_cv_sys_file_offset_bits],
-    [unknown],
-      [_AC_SYS_LARGEFILE_MACRO_VALUE([_LARGE_FILES], [1],
-         [ac_cv_sys_large_files],
-         [Define for large files, on AIX-style hosts.],
-         [_AC_SYS_LARGEFILE_TEST_INCLUDES])],
-    [64],
-      [gl_YEAR2038_BODY([])])])
-])# AC_SYS_LARGEFILE
+[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
+  AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE])
+  AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
+])])
 ])# m4_ifndef AC_SYS_YEAR2038
 
 # Enable large files on systems where this is implemented by Gnulib, not by the
diff --git a/m4/year2038.m4 b/m4/year2038.m4
deleted file mode 100644
index 2e4427e6fa..0000000000
--- a/m4/year2038.m4
+++ /dev/null
@@ -1,132 +0,0 @@
-# year2038.m4 serial 8
-dnl Copyright (C) 2017-2022 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl Attempt to ensure that 'time_t' can go past the year 2038 and that
-dnl the functions 'time', 'stat', etc. work with post-2038 timestamps.
-
-m4_ifdef([AC_SYS_YEAR2038], [
-  AC_DEFUN([gl_YEAR2038_EARLY])
-  AC_DEFUN([gl_YEAR2038], [AC_SYS_YEAR2038])
-  AC_DEFUN([gl_YEAR2038_BODY], [_AC_SYS_YEAR2038])
-], [
-
-AC_DEFUN([gl_YEAR2038_EARLY],
-[
-  AC_REQUIRE([AC_CANONICAL_HOST])
-  case "$host_os" in
-    mingw*)
-      AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
-        [For 64-bit time_t on 32-bit mingw.])
-      ;;
-  esac
-])
-
-# gl_YEAR2038_TEST_INCLUDES
-# -------------------------
-AC_DEFUN([gl_YEAR2038_TEST_INCLUDES],
-[[
-  #include <time.h>
-  /* Check that time_t can represent 2**32 - 1 correctly.  */
-  #define LARGE_TIME_T \\
-    ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))
-  int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535
-                           && LARGE_TIME_T % 65537 == 0)
-                          ? 1 : -1];
-]])
-
-# gl_YEAR2038_BODY(REQUIRE-YEAR2038-SAFE)
------------------------------------------
-AC_DEFUN([gl_YEAR2038_BODY],
-[
- AC_ARG_ENABLE([year2038],
-   [  --disable-year2038      omit support for timestamps past the year 2038])
- AS_IF([test "$enable_year2038" != no],
- [
-  dnl On many systems, time_t is already a 64-bit type.
-  dnl On those systems where time_t is still 32-bit, it requires kernel
-  dnl and libc support to make it 64-bit. For glibc 2.34 and later on Linux,
-  dnl defining _TIME_BITS=64 and _FILE_OFFSET_BITS=64 is needed on x86 and ARM.
-  dnl
-  dnl On native Windows, the system include files define types __time32_t
-  dnl and __time64_t. By default, time_t is an alias of
-  dnl   - __time32_t on 32-bit mingw,
-  dnl   - __time64_t on 64-bit mingw and on MSVC (since MSVC 8).
-  dnl But when compiling with -D__MINGW_USE_VC2005_COMPAT, time_t is an
-  dnl alias of __time64_t.
-  dnl And when compiling with -D_USE_32BIT_TIME_T, time_t is an alias of
-  dnl __time32_t.
-  AC_CACHE_CHECK([for time_t past the year 2038], [gl_cv_type_time_t_y2038],
-    [AC_COMPILE_IFELSE(
-       [AC_LANG_SOURCE([gl_YEAR2038_TEST_INCLUDES])],
-       [gl_cv_type_time_t_y2038=yes], [gl_cv_type_time_t_y2038=no])
-    ])
-  if test "$gl_cv_type_time_t_y2038" = no; then
-    AC_CACHE_CHECK([for 64-bit time_t with _TIME_BITS=64],
-      [gl_cv_type_time_t_bits_macro],
-      [AC_COMPILE_IFELSE(
-         [AC_LANG_SOURCE([[#define _TIME_BITS 64
-                           #define _FILE_OFFSET_BITS 64
-                           ]gl_YEAR2038_TEST_INCLUDES])],
-         [gl_cv_type_time_t_bits_macro=yes],
-         [gl_cv_type_time_t_bits_macro=no])
-      ])
-    if test "$gl_cv_type_time_t_bits_macro" = yes; then
-      AC_DEFINE([_TIME_BITS], [64],
-        [Number of bits in a timestamp, on hosts where this is settable.])
-      dnl AC_SYS_LARGFILE also defines this; it's OK if we do too.
-      AC_DEFINE([_FILE_OFFSET_BITS], [64],
-        [Number of bits in a file offset, on hosts where this is settable.])
-      gl_cv_type_time_t_y2038=yes
-    fi
-  fi
-  if test $gl_cv_type_time_t_y2038 = no; then
-    AC_COMPILE_IFELSE(
-      [AC_LANG_SOURCE(
-         [[#ifdef _USE_32BIT_TIME_T
-             int ok;
-           #else
-             error fail
-           #endif
-         ]])],
-      [AC_MSG_FAILURE(
-         [The 'time_t' type stops working after January 2038.
-          Remove _USE_32BIT_TIME_T from the compiler flags.])],
-      [# If not cross-compiling and $1 says we should check,
-       # and 'touch' works with a large timestamp, then evidently wider time_t
-       # is desired and supported, so fail and ask the builder to fix the
-       # problem.  Otherwise, just warn the builder.
-       m4_ifval([$1],
-         [if test $cross_compiling = no \
-             && TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null; 
then
-            case `TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null` in
-              *'Feb  7  2106'* | *'Feb  7 17:10'*)
-                AC_MSG_FAILURE(
-                  [The 'time_t' type stops working after January 2038,
-                   and your system appears to support a wider 'time_t'.
-                   Try configuring with 'CC="${CC} -m64"'.
-                   To build with a 32-bit time_t anyway (not recommended),
-                   configure with '--disable-year2038'.]);;
-            esac
-            rm -f conftest.time
-          fi])
-       if test "$gl_warned_about_y2038" != yes; then
-         AC_MSG_WARN(
-           [The 'time_t' type stops working after January 2038,
-            and this package needs a wider 'time_t' type
-            if there is any way to access timestamps after that.
-            Configure with 'CC="${CC} -m64"' perhaps?])
-         gl_warned_about_y2038=yes
-       fi
-      ])
-  fi])
-])
-
-AC_DEFUN([gl_YEAR2038],
-[
-  gl_YEAR2038_BODY([require-year2038-safe])
-])
-
-]) # m4_ifndef AC_SYS_YEAR2038
diff --git a/modules/largefile b/modules/largefile
index 9e1d9f052a..fb4f6c4cbb 100644
--- a/modules/largefile
+++ b/modules/largefile
@@ -1,5 +1,5 @@
 Description:
-Support for files larger than 2 GB.
+Support for files 2 GiB and larger.
 
 Comment:
 This module should not be used as a dependency from a test module,
@@ -8,12 +8,10 @@ have side effects on the compilation of the main modules in 
lib/.
 
 Files:
 m4/largefile.m4
-m4/year2038.m4
 
 Depends-on:
 
 configure.ac-early:
-AC_REQUIRE([gl_YEAR2038_EARLY])
 AC_REQUIRE([AC_SYS_LARGEFILE])
 
 configure.ac:
diff --git a/modules/year2038 b/modules/year2038
index af145b8a02..40028e43e6 100644
--- a/modules/year2038
+++ b/modules/year2038
@@ -1,5 +1,5 @@
 Description:
-Attempt to ensure that 'time_t' is a 64-bit type.
+Attempt to ensure that 'time_t' can go past the year 2038.
 
 Comment:
 This module should not be used as a dependency from a test module,
@@ -7,15 +7,12 @@ otherwise when this module occurs as a tests-related module, 
it will
 have side effects on the compilation of the main modules in lib/.
 
 Files:
-m4/year2038.m4
 
 Depends-on:
-
-configure.ac-early:
-AC_REQUIRE([gl_YEAR2038_EARLY])
+largefile
 
 configure.ac:
-AC_REQUIRE([gl_YEAR2038])
+AC_REQUIRE([AC_SYS_YEAR2038])
 
 Makefile.am:
 
-- 
2.38.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]