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