Debian Codegraph @

gnulib/m4/largefile.m4

raw
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.
3
4 # Copyright 1992-1996, 1998-2022 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
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.
14 AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
15 [
16 m4_ifndef([AC_SYS_YEAR2038], [
17 AC_REQUIRE([AC_CANONICAL_HOST])
18 AC_FUNC_FSEEKO
19 case "$host_os" in
20 hpux*)
21 AC_DEFINE([_LARGEFILE_SOURCE], [1],
22 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
23 ;;
24 esac
25 ])
26 ])
27
28 # Work around a problem in Autoconf through 2.71 on glibc 2.34+
29 # with _TIME_BITS. Also, work around a problem in autoconf <= 2.69:
30 # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
31 # or configures them incorrectly in some cases.
32 m4_version_prereq([2.70], [], [
33
34 # _AC_SYS_LARGEFILE_TEST_INCLUDES
35 # -------------------------------
36 m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
37 [#include <sys/types.h>
38 /* Check that off_t can represent 2**63 - 1 correctly.
39 We can't simply define LARGE_OFF_T to be 9223372036854775807,
40 since some C++ compilers masquerading as C compilers
41 incorrectly reject 9223372036854775807. */
42 #define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
43 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
44 && LARGE_OFF_T % 2147483647 == 1)
45 ? 1 : -1]];[]dnl
46 ])
47 ])# m4_version_prereq 2.70
48
49 m4_ifndef([AC_SYS_YEAR2038], [
50
51 # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
52 # CACHE-VAR,
53 # DESCRIPTION,
54 # PROLOGUE, [FUNCTION-BODY])
55 # --------------------------------------------------------
56 m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
57 [AC_CACHE_CHECK([for $1 value needed for large files], [$3],
58 [while :; do
59 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
60 [AC_LANG_PROGRAM([$5], [$6])],
61 [$3=no; break])
62 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
63 [AC_LANG_PROGRAM([#undef $1
64 #define $1 $2
65 $5], [$6])],
66 [$3=$2; break])
67 $3=unknown
68 break
69 done])
70 case $$3 in #(
71 no | unknown) ;;
72 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
73 esac
74 rm -rf conftest*[]dnl
75 ])# _AC_SYS_LARGEFILE_MACRO_VALUE
76
77
78 # AC_SYS_LARGEFILE
79 # ----------------
80 # By default, many hosts won't let programs access large files;
81 # one must use special compiler options to get large-file access to work.
82 # For more details about this brain damage please see:
83 # http://www.unix.org/version2/whatsnew/lfs20mar.html
84 # Additionally, on Linux file systems with 64-bit inodes a file that happens
85 # to have a 64-bit inode number cannot be accessed by 32-bit applications on
86 # Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
87 AC_DEFUN([AC_SYS_LARGEFILE],
88 [AC_ARG_ENABLE(largefile,
89 [ --disable-largefile omit support for large files])
90 AS_IF([test "$enable_largefile" != no],
91 [AC_CACHE_CHECK([for special C compiler options needed for large files],
92 ac_cv_sys_largefile_CC,
93 [ac_cv_sys_largefile_CC=no
94 if test "$GCC" != yes; then
95 ac_save_CC=$CC
96 while :; do
97 # IRIX 6.2 and later do not support large files by default,
98 # so use the C compiler's -n32 option if that helps.
99 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
100 AC_COMPILE_IFELSE([], [break])
101 CC="$CC -n32"
102 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
103 break
104 done
105 CC=$ac_save_CC
106 rm -f conftest.$ac_ext
107 fi])
108 if test "$ac_cv_sys_largefile_CC" != no; then
109 CC=$CC$ac_cv_sys_largefile_CC
110 fi
111
112 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
113 ac_cv_sys_file_offset_bits,
114 [Number of bits in a file offset, on hosts where this is settable.],
115 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
116 AS_CASE([$ac_cv_sys_file_offset_bits],
117 [unknown],
118 [_AC_SYS_LARGEFILE_MACRO_VALUE([_LARGE_FILES], [1],
119 [ac_cv_sys_large_files],
120 [Define for large files, on AIX-style hosts.],
121 [_AC_SYS_LARGEFILE_TEST_INCLUDES])],
122 [64],
123 [gl_YEAR2038_BODY([])])])
124 ])# AC_SYS_LARGEFILE
125 ])# m4_ifndef AC_SYS_YEAR2038
126
127 # Enable large files on systems where this is implemented by Gnulib, not by the
128 # system headers.
129 # Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib
130 # overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively.
131 AC_DEFUN([gl_LARGEFILE],
132 [
133 AC_REQUIRE([AC_CANONICAL_HOST])
134 case "$host_os" in
135 mingw*)
136 dnl Native Windows.
137 dnl mingw64 defines off_t to a 64-bit type already, if
138 dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE.
139 AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64],
140 [AC_COMPILE_IFELSE(
141 [AC_LANG_PROGRAM(
142 [[#include <sys/types.h>
143 int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1];
144 ]],
145 [[]])],
146 [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no])
147 ])
148 if test $gl_cv_type_off_t_64 = no; then
149 WINDOWS_64_BIT_OFF_T=1
150 else
151 WINDOWS_64_BIT_OFF_T=0
152 fi
153 dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat'
154 dnl to 'struct _stat32i64' or 'struct _stat64' (depending on
155 dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member.
156 AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64],
157 [AC_COMPILE_IFELSE(
158 [AC_LANG_PROGRAM(
159 [[#include <sys/types.h>
160 struct stat buf;
161 int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1];
162 ]],
163 [[]])],
164 [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no])
165 ])
166 if test $gl_cv_member_st_size_64 = no; then
167 WINDOWS_64_BIT_ST_SIZE=1
168 else
169 WINDOWS_64_BIT_ST_SIZE=0
170 fi
171 ;;
172 *)
173 dnl Nothing to do on gnulib's side.
174 dnl A 64-bit off_t is
175 dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX,
176 dnl OSF/1, Cygwin,
177 dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on
178 dnl glibc, HP-UX, Solaris,
179 dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX,
180 dnl - impossible to achieve on Minix 3.1.8.
181 WINDOWS_64_BIT_OFF_T=0
182 WINDOWS_64_BIT_ST_SIZE=0
183 ;;
184 esac
185 ])