VirtualBox

source: kBuild/trunk/src/grep/m4/stdio_h.m4

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:eol-style set to LF
File size: 11.2 KB
Line 
1# stdio_h.m4 serial 56
2dnl Copyright (C) 2007-2021 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN_ONCE([gl_STDIO_H],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AH_VERBATIM([MINGW_ANSI_STDIO],
11[/* Use GNU style printf and scanf. */
12#ifndef __USE_MINGW_ANSI_STDIO
13# undef __USE_MINGW_ANSI_STDIO
14#endif
15])
16 AC_DEFINE([__USE_MINGW_ANSI_STDIO])
17 gl_NEXT_HEADERS([stdio.h])
18
19 dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
20 dnl inttypes.h behave like gnu instead of system; we must give our
21 dnl printf wrapper the right attribute to match.
22 AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros],
23 [gl_cv_func_printf_attribute_flavor],
24 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
25 #define __STDC_FORMAT_MACROS 1
26 #include <stdio.h>
27 #include <inttypes.h>
28 /* For non-mingw systems, compilation will trivially succeed.
29 For mingw, compilation will succeed for older mingw (system
30 printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */
31 #if (defined _WIN32 && ! defined __CYGWIN__) && \
32 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
33 extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1];
34 #endif
35 ]])], [gl_cv_func_printf_attribute_flavor=system],
36 [gl_cv_func_printf_attribute_flavor=gnu])])
37 if test "$gl_cv_func_printf_attribute_flavor" = gnu; then
38 AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1],
39 [Define to 1 if printf and friends should be labeled with
40 attribute "__gnu_printf__" instead of "__printf__"])
41 fi
42
43 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c"
44 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
45 dnl also an optimization, to avoid performing a configure check whose result
46 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
47 dnl or GNULIB_NONBLOCKING redundant.
48 m4_ifdef([gl_NONBLOCKING_IO], [
49 gl_NONBLOCKING_IO
50 if test $gl_cv_have_nonblocking != yes; then
51 REPLACE_STDIO_READ_FUNCS=1
52 AC_LIBOBJ([stdio-read])
53 fi
54 ])
55
56 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
57 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
58 dnl also an optimization, to avoid performing a configure check whose result
59 dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
60 dnl GNULIB_SIGPIPE redundant.
61 m4_ifdef([gl_SIGNAL_SIGPIPE], [
62 gl_SIGNAL_SIGPIPE
63 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
64 REPLACE_STDIO_WRITE_FUNCS=1
65 AC_LIBOBJ([stdio-write])
66 fi
67 ])
68 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
69 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
70 dnl also an optimization, to avoid performing a configure check whose result
71 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
72 dnl or GNULIB_NONBLOCKING redundant.
73 m4_ifdef([gl_NONBLOCKING_IO], [
74 gl_NONBLOCKING_IO
75 if test $gl_cv_have_nonblocking != yes; then
76 REPLACE_STDIO_WRITE_FUNCS=1
77 AC_LIBOBJ([stdio-write])
78 fi
79 ])
80
81 dnl Check for declarations of anything we want to poison if the
82 dnl corresponding gnulib module is not in use, and which is not
83 dnl guaranteed by both C89 and C11.
84 gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
85 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
86 renameat snprintf tmpfile vdprintf vsnprintf])
87
88 AC_REQUIRE([AC_C_RESTRICT])
89
90 AC_CHECK_DECLS_ONCE([fcloseall])
91 if test $ac_cv_have_decl_fcloseall = no; then
92 HAVE_DECL_FCLOSEALL=0
93 fi
94])
95
96# gl_STDIO_MODULE_INDICATOR([modulename])
97# sets the shell variable that indicates the presence of the given module
98# to a C preprocessor expression that will evaluate to 1.
99# This macro invocation must not occur in macros that are AC_REQUIREd.
100AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
101[
102 dnl Ensure to expand the default settings once only.
103 gl_STDIO_H_REQUIRE_DEFAULTS
104 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
105 dnl Define it also as a C macro, for the benefit of the unit tests.
106 gl_MODULE_INDICATOR_FOR_TESTS([$1])
107])
108
109# Initializes the default values for AC_SUBSTed shell variables.
110# This macro must not be AC_REQUIREd. It must only be invoked, and only
111# outside of macros or in macros that are not AC_REQUIREd.
112AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
113[
114 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTC])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTS])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREAD])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREOPEN])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSCANF])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEK])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEKO])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF_POSIX])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTC])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTCHAR])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTS])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMOVE])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAME])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX])
168 dnl Support Microsoft deprecated alias function names by default.
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1])
170 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1])
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FILENO], [1])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETW], [1])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTW], [1])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TEMPNAM], [1])
175 ])
176 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS])
177 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
178])
179
180AC_DEFUN([gl_STDIO_H_DEFAULTS],
181[
182 dnl Assume proper GNU behavior unless another module says otherwise.
183 HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL])
184 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE])
185 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO])
186 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
187 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM])
188 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE])
189 HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
190 HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
191 HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
192 HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
193 HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
194 HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
195 HAVE_PCLOSE=1; AC_SUBST([HAVE_PCLOSE])
196 HAVE_POPEN=1; AC_SUBST([HAVE_POPEN])
197 HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
198 HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
199 HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
200 REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF])
201 REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE])
202 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN])
203 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
204 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
205 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
206 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE])
207 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
208 REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK])
209 REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO])
210 REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL])
211 REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO])
212 REPLACE_GETDELIM=0; AC_SUBST([REPLACE_GETDELIM])
213 REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE])
214 REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF])
215 REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR])
216 REPLACE_POPEN=0; AC_SUBST([REPLACE_POPEN])
217 REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF])
218 REPLACE_REMOVE=0; AC_SUBST([REPLACE_REMOVE])
219 REPLACE_RENAME=0; AC_SUBST([REPLACE_RENAME])
220 REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT])
221 REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
222 REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
223 REPLACE_STDIO_READ_FUNCS=0; AC_SUBST([REPLACE_STDIO_READ_FUNCS])
224 REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
225 REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE])
226 REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
227 REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF])
228 REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
229 REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF])
230 REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF])
231 REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
232])
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette