blob: 72c0c0e413b2d93ce8eb0f5040c8e5b45d6fdcfa [file] [log] [blame]
Patrick Williams8e7b46e2023-05-01 14:19:06 -05001From c2bea3d033b5abd44698722d8eedc2b87373b33b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 2 Apr 2023 10:42:43 -0700
4Subject: [PATCH] largefile.m4: Update from latest gnulib
5
6brings in latest largefile specific changes which autoconf 2.72+ requires
7
8Upstream-Status: Inappropriate [Drop it with new emacs release which has it]
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 m4/largefile.m4 | 330 ++++++++++++++++++++++++++++++++++++++----------
12 1 file changed, 263 insertions(+), 67 deletions(-)
13
14diff --git a/m4/largefile.m4 b/m4/largefile.m4
15index 3e8b5e3..7fb81b8 100644
16--- a/m4/largefile.m4
17+++ b/m4/largefile.m4
18@@ -1,7 +1,7 @@
19 # Enable large files on systems where this is not the default.
20 # Enable support for files on Linux file systems with 64-bit inode numbers.
21
22-# Copyright 1992-1996, 1998-2022 Free Software Foundation, Inc.
23+# Copyright 1992-1996, 1998-2023 Free Software Foundation, Inc.
24 # This file is free software; the Free Software Foundation
25 # gives unlimited permission to copy and/or distribute it,
26 # with or without modifications, as long as this notice is preserved.
27@@ -10,8 +10,9 @@
28 # It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this
29 # setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko
30 # and ftello in C++ mode as well.
31+# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038.
32 AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
33-[
34+ m4_ifndef([AC_SYS_YEAR2038], [[
35 AC_REQUIRE([AC_CANONICAL_HOST])
36 AC_FUNC_FSEEKO
37 case "$host_os" in
38@@ -20,10 +21,10 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
39 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
40 ;;
41 esac
42-])
43+ ]])
44+)
45
46-# Work around a problem in Autoconf through at least 2.71 on glibc 2.34+
47-# with _TIME_BITS. Also, work around a problem in autoconf <= 2.69:
48+# Work around a problem in autoconf <= 2.69:
49 # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
50 # or configures them incorrectly in some cases.
51 m4_version_prereq([2.70], [], [
52@@ -43,33 +44,258 @@ m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
53 ])
54 ])# m4_version_prereq 2.70
55
56+# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier.
57+# This code is taken from Autoconf master.
58+m4_ifndef([AC_SYS_YEAR2038], [
59+
60+# _AC_SYS_YEAR2038_TEST_CODE
61+# --------------------------
62+# C code used to probe for time_t that can represent time points more
63+# than 2**31 - 1 seconds after the epoch. With the usual Unix epoch,
64+# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian),
65+# hence the name.
66+AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE],
67+[[
68+ #include <time.h>
69+ /* Check that time_t can represent 2**32 - 1 correctly. */
70+ #define LARGE_TIME_T \\
71+ ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))
72+ int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535
73+ && LARGE_TIME_T % 65537 == 0)
74+ ? 1 : -1];
75+]])
76+
77+# _AC_SYS_YEAR2038_OPTIONS
78+# ------------------------
79+# List of known ways to enable support for large time_t. If you change
80+# this list you probably also need to change the AS_CASE at the end of
81+# _AC_SYS_YEAR2038_PROBE.
82+m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
83+ ["none needed"] dnl 64-bit and newer 32-bit Unix
84+ ["-D_TIME_BITS=64"] dnl glibc 2.34 with some 32-bit ABIs
85+ ["-D__MINGW_USE_VC2005_COMPAT"] dnl 32-bit MinGW
86+ ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"]
87+ dnl 32-bit MinGW (misconfiguration)
88+))
89+
90+# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED])
91+# -----------------------------------------
92+# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent
93+# time points more than 2**31 - 1 seconds after the epoch (dates after
94+# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
95+# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to
96+# "support not detected" if none of them worked. Then, set compilation
97+# options and #defines as necessary to enable large time_t support.
98+#
99+# Note that we do not test whether mktime, localtime, etc. handle
100+# large values of time_t correctly, as that would require use of
101+# AC_TRY_RUN. Note also that some systems only support large time_t
102+# together with large off_t.
103+#
104+# If support is not detected, the behavior depends on which of the
105+# top-level AC_SYS_YEAR2038 macros was used (see below).
106+#
107+# If you change this macro you may also need to change
108+# _AC_SYS_YEAR2038_OPTIONS.
109+AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
110+[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038],
111+ [ac_cv_sys_year2038_opts],
112+ [ac_save_CPPFLAGS="$CPPFLAGS"
113+ ac_opt_found=no
114+ for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do
115+ AS_IF([test x"$ac_opt" != x"none needed"],
116+ [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
117+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])],
118+ [ac_cv_sys_year2038_opts="$ac_opt"
119+ ac_opt_found=yes])
120+ test $ac_opt_found = no || break
121+ done
122+ CPPFLAGS="$ac_save_CPPFLAGS"
123+ test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"])
124+
125+ac_have_year2038=yes
126+AS_CASE([$ac_cv_sys_year2038_opts],
127+ ["none needed"], [],
128+ ["support not detected"],
129+ [ac_have_year2038=no
130+ AS_CASE([$enable_year2038],
131+ [yes],
132+ [# If we're not cross compiling and 'touch' works with a large
133+ # timestamp, then we can presume the system supports wider time_t
134+ # *somehow* and we just weren't able to detect it. One common
135+ # case that we deliberately *don't* probe for is a system that
136+ # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
137+ # wide time_t. (It would be inappropriate for us to override an
138+ # intentional use of -m32.) Error out, demanding use of
139+ # --disable-year2038 if this is intentional.
140+ AS_IF([test $cross_compiling = no],
141+ [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
142+ [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
143+ [*'Feb 7 2106'* | *'Feb 7 17:10'*],
144+ [AC_MSG_FAILURE(m4_text_wrap(
145+ [this system appears to support timestamps after January 2038,
146+ but no mechanism for enabling wide 'time_t' was detected.
147+ Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
148+ To proceed with 32-bit time_t, configure with '--disable-year2038'.],
149+ [], [], [55]))])])])])],
150+
151+ ["-D_TIME_BITS=64"],
152+ [AC_DEFINE([_TIME_BITS], [64],
153+ [Number of bits in time_t, on hosts where this is settable.])],
154+
155+ ["-D__MINGW_USE_VC2005_COMPAT=1"],
156+ [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
157+ [Define to 1 on platforms where this makes time_t a 64-bit type.])],
158
159-# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
160-# CACHE-VAR,
161-# DESCRIPTION,
162-# PROLOGUE, [FUNCTION-BODY])
163-# --------------------------------------------------------
164-m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
165-[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
166-[while :; do
167- m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
168- [AC_LANG_PROGRAM([$5], [$6])],
169- [$3=no; break])
170- m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
171- [AC_LANG_PROGRAM([#undef $1
172-#define $1 $2
173-$5], [$6])],
174- [$3=$2; break])
175- $3=unknown
176- break
177-done])
178-case $$3 in #(
179- no | unknown) ;;
180- *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
181-esac
182-rm -rf conftest*[]dnl
183-])# _AC_SYS_LARGEFILE_MACRO_VALUE
184+ ["-U_USE_32_BIT_TIME_T"*],
185+ [AC_MSG_FAILURE(m4_text_wrap(
186+ [the 'time_t' type is currently forced to be 32-bit.
187+ It will stop working after January 2038.
188+ Remove _USE_32BIT_TIME_T from the compiler flags.],
189+ [], [], [55]))],
190+
191+ [AC_MSG_ERROR(
192+ [internal error: bad value for \$ac_cv_sys_year2038_opts])])
193+])
194+
195+# _AC_SYS_YEAR2038_ENABLE
196+# -----------------------
197+# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
198+# Depending on which of the YEAR2038 macros was used, add either an
199+# --enable-year2038, or a --disable-year2038, or no option at all to
200+# the configure script. Note that this is expanded very late and
201+# therefore there cannot be any code in the AC_ARG_ENABLE. The
202+# default value for enable_year2038 is emitted unconditionally
203+# because the generated code always looks at this variable.
204+m4_define([_AC_SYS_YEAR2038_ENABLE],
205+[m4_divert_text([DEFAULTS],
206+ m4_provide_if([AC_SYS_YEAR2038],
207+ [enable_year2038=yes],
208+ [enable_year2038=no]))]dnl
209+[AC_ARG_ENABLE([year2038],
210+ m4_provide_if([AC_SYS_YEAR2038],
211+ [AS_HELP_STRING([--disable-year2038],
212+ [do not support timestamps after 2038])],
213+ [AS_HELP_STRING([--enable-year2038],
214+ [support timestamps after 2038])]))])
215+
216+# _AC_SYS_YEAR2038_OPT_IN
217+# -----------------------
218+# If the --enable-year2038 option is given to configure, attempt to
219+# detect and activate support for large time_t on 32-bit systems.
220+# This macro is automatically invoked by AC_SYS_LARGEFILE when large
221+# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE
222+# to avoid a dependency loop, and is therefore unsafe to expose as a
223+# documented macro.
224+AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
225+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
226+ AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
227+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
228+])])
229+
230+# AC_SYS_YEAR2038
231+# ---------------
232+# Attempt to detect and activate support for large time_t.
233+# On systems where time_t is not always 64 bits, this probe can be
234+# skipped by passing the --disable-year2038 option to configure.
235+AC_DEFUN([AC_SYS_YEAR2038],
236+[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl
237+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
238+ AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
239+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
240+])])
241+
242+# _AC_SYS_LARGEFILE_TEST_CODE
243+# ---------------------------
244+# C code used to probe for large file support.
245+m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
246+[@%:@include <sys/types.h>
247+ /* Check that off_t can represent 2**63 - 1 correctly.
248+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
249+ since some C++ compilers masquerading as C compilers
250+ incorrectly reject 9223372036854775807. */
251+@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
252+ int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
253+ && LARGE_OFF_T % 2147483647 == 1)
254+ ? 1 : -1]];[]dnl
255+])
256+
257+# _AC_SYS_LARGEFILE_OPTIONS
258+# -------------------------
259+# List of known ways to enable support for large files. If you change
260+# this list you probably also need to change the AS_CASE at the end of
261+# _AC_SYS_LARGEFILE_PROBE.
262+m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
263+ ["none needed"] dnl Most current systems
264+ ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec
265+ ["-D_LARGE_FILES=1"] dnl AIX (which versions?)
266+ ["-n32"] dnl Irix 6.2 w/ SGI compiler
267+))
268+
269+# _AC_SYS_LARGEFILE_PROBE
270+# -----------------------
271+# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set
272+# the cache variable ac_cv_sys_largefile_opts to one of the values in
273+# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if
274+# none of the options in that list worked. Then, set compilation
275+# options and #defines as necessary to enable large file support.
276+#
277+# If large file support is not detected, the behavior depends on which of
278+# the top-level AC_SYS_LARGEFILE macros was used (see below).
279+#
280+# If you change this macro you may also need to change
281+# _AC_SYS_LARGEFILE_OPTIONS.
282+AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
283+[AC_CACHE_CHECK([for $CC option to enable large file support],
284+ [ac_cv_sys_largefile_opts],
285+ [ac_save_CC="$CC"
286+ ac_opt_found=no
287+ for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
288+ AS_IF([test x"$ac_opt" != x"none needed"],
289+ [CC="$ac_save_CC $ac_opt"])
290+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
291+ [ac_cv_sys_largefile_opts="$ac_opt"
292+ ac_opt_found=yes])
293+ test $ac_opt_found = no || break
294+ done
295+ CC="$ac_save_CC"
296+ test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
297+
298+ac_have_largefile=yes
299+AS_CASE([$ac_cv_sys_largefile_opts],
300+ ["none needed"], [],
301+ ["support not detected"],
302+ [ac_have_largefile=no],
303+
304+ ["-D_FILE_OFFSET_BITS=64"],
305+ [AC_DEFINE([_FILE_OFFSET_BITS], [64],
306+ [Number of bits in a file offset, on hosts where this is settable.])],
307+
308+ ["-D_LARGE_FILES=1"],
309+ [AC_DEFINE([_LARGE_FILES], [1],
310+ [Define to 1 on platforms where this makes off_t a 64-bit type.])],
311+
312+ ["-n32"],
313+ [CC="$CC -n32"],
314+
315+ [AC_MSG_ERROR(
316+ [internal error: bad value for \$ac_cv_sys_largefile_opts])])
317+
318+_AC_SYS_YEAR2038_OPT_IN
319+])
320
321+# _AC_SYS_LARGEFILE_ENABLE
322+# ------------------------
323+# Subroutine of AC_SYS_LARGEFILE. Note that this
324+# is expanded very late and therefore there cannot be any code in the
325+# AC_ARG_ENABLE. The default value for enable_largefile is emitted
326+# unconditionally because the generated shell code always looks at
327+# this variable.
328+m4_define([_AC_SYS_LARGEFILE_ENABLE],
329+[m4_divert_text([DEFAULTS],
330+ enable_largefile=yes)]dnl
331+[AC_ARG_ENABLE([largefile],
332+ [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])
333
334 # AC_SYS_LARGEFILE
335 # ----------------
336@@ -80,44 +306,14 @@ rm -rf conftest*[]dnl
337 # Additionally, on Linux file systems with 64-bit inodes a file that happens
338 # to have a 64-bit inode number cannot be accessed by 32-bit applications on
339 # Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
340+# This macro allows configuration to continue if the system doesn't support
341+# large files.
342 AC_DEFUN([AC_SYS_LARGEFILE],
343-[AC_ARG_ENABLE(largefile,
344- [ --disable-largefile omit support for large files])
345-AS_IF([test "$enable_largefile" != no],
346- [AC_CACHE_CHECK([for special C compiler options needed for large files],
347- ac_cv_sys_largefile_CC,
348- [ac_cv_sys_largefile_CC=no
349- if test "$GCC" != yes; then
350- ac_save_CC=$CC
351- while :; do
352- # IRIX 6.2 and later do not support large files by default,
353- # so use the C compiler's -n32 option if that helps.
354- AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
355- AC_COMPILE_IFELSE([], [break])
356- CC="$CC -n32"
357- AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
358- break
359- done
360- CC=$ac_save_CC
361- rm -f conftest.$ac_ext
362- fi])
363- if test "$ac_cv_sys_largefile_CC" != no; then
364- CC=$CC$ac_cv_sys_largefile_CC
365- fi
366-
367- _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
368- ac_cv_sys_file_offset_bits,
369- [Number of bits in a file offset, on hosts where this is settable.],
370- [_AC_SYS_LARGEFILE_TEST_INCLUDES])
371- AS_CASE([$ac_cv_sys_file_offset_bits],
372- [unknown],
373- [_AC_SYS_LARGEFILE_MACRO_VALUE([_LARGE_FILES], [1],
374- [ac_cv_sys_large_files],
375- [Define for large files, on AIX-style hosts.],
376- [_AC_SYS_LARGEFILE_TEST_INCLUDES])],
377- [64],
378- [gl_YEAR2038_BODY([])])])
379-])# AC_SYS_LARGEFILE
380+[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
381+ AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE])
382+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
383+])])
384+])# m4_ifndef AC_SYS_YEAR2038
385
386 # Enable large files on systems where this is implemented by Gnulib, not by the
387 # system headers.
388--
3892.40.0
390