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