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