diff options
Diffstat (limited to 'gl/m4/stdio_h.m4')
-rw-r--r-- | gl/m4/stdio_h.m4 | 200 |
1 files changed, 119 insertions, 81 deletions
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4 index ebade067..e7043838 100644 --- a/gl/m4/stdio_h.m4 +++ b/gl/m4/stdio_h.m4 | |||
@@ -1,25 +1,45 @@ | |||
1 | # stdio_h.m4 serial 43 | 1 | # stdio_h.m4 serial 56 |
2 | dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_STDIO_H], | 7 | AC_DEFUN_ONCE([gl_STDIO_H], |
8 | [ | 8 | [ |
9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | 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]) | ||
10 | gl_NEXT_HEADERS([stdio.h]) | 17 | gl_NEXT_HEADERS([stdio.h]) |
11 | 18 | ||
12 | dnl No need to create extra modules for these functions. Everyone who uses | 19 | dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and |
13 | dnl <stdio.h> likely needs them. | 20 | dnl inttypes.h behave like gnu instead of system; we must give our |
14 | GNULIB_FSCANF=1 | 21 | dnl printf wrapper the right attribute to match. |
15 | gl_MODULE_INDICATOR([fscanf]) | 22 | AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros], |
16 | GNULIB_SCANF=1 | 23 | [gl_cv_func_printf_attribute_flavor], |
17 | gl_MODULE_INDICATOR([scanf]) | 24 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
18 | GNULIB_FGETC=1 | 25 | #define __STDC_FORMAT_MACROS 1 |
19 | GNULIB_GETC=1 | 26 | #include <stdio.h> |
20 | GNULIB_GETCHAR=1 | 27 | #include <inttypes.h> |
21 | GNULIB_FGETS=1 | 28 | /* For non-mingw systems, compilation will trivially succeed. |
22 | GNULIB_FREAD=1 | 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 | |||
23 | dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" | 43 | dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" |
24 | dnl "expected source file, required through AC_LIBSOURCES, not found". It is | 44 | dnl "expected source file, required through AC_LIBSOURCES, not found". It is |
25 | dnl also an optimization, to avoid performing a configure check whose result | 45 | dnl also an optimization, to avoid performing a configure check whose result |
@@ -33,18 +53,6 @@ AC_DEFUN([gl_STDIO_H], | |||
33 | fi | 53 | fi |
34 | ]) | 54 | ]) |
35 | 55 | ||
36 | dnl No need to create extra modules for these functions. Everyone who uses | ||
37 | dnl <stdio.h> likely needs them. | ||
38 | GNULIB_FPRINTF=1 | ||
39 | GNULIB_PRINTF=1 | ||
40 | GNULIB_VFPRINTF=1 | ||
41 | GNULIB_VPRINTF=1 | ||
42 | GNULIB_FPUTC=1 | ||
43 | GNULIB_PUTC=1 | ||
44 | GNULIB_PUTCHAR=1 | ||
45 | GNULIB_FPUTS=1 | ||
46 | GNULIB_PUTS=1 | ||
47 | GNULIB_FWRITE=1 | ||
48 | dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" | 56 | dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" |
49 | dnl "expected source file, required through AC_LIBSOURCES, not found". It is | 57 | dnl "expected source file, required through AC_LIBSOURCES, not found". It is |
50 | dnl also an optimization, to avoid performing a configure check whose result | 58 | dnl also an optimization, to avoid performing a configure check whose result |
@@ -76,73 +84,103 @@ AC_DEFUN([gl_STDIO_H], | |||
76 | gl_WARN_ON_USE_PREPARE([[#include <stdio.h> | 84 | gl_WARN_ON_USE_PREPARE([[#include <stdio.h> |
77 | ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen | 85 | ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen |
78 | renameat snprintf tmpfile vdprintf vsnprintf]) | 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 | ||
79 | ]) | 94 | ]) |
80 | 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. | ||
81 | AC_DEFUN([gl_STDIO_MODULE_INDICATOR], | 100 | AC_DEFUN([gl_STDIO_MODULE_INDICATOR], |
82 | [ | 101 | [ |
83 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | 102 | dnl Ensure to expand the default settings once only. |
84 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | 103 | gl_STDIO_H_REQUIRE_DEFAULTS |
85 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | 104 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
86 | dnl Define it also as a C macro, for the benefit of the unit tests. | 105 | dnl Define it also as a C macro, for the benefit of the unit tests. |
87 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) | 106 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
88 | ]) | 107 | ]) |
89 | 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. | ||
112 | AC_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 | |||
90 | AC_DEFUN([gl_STDIO_H_DEFAULTS], | 180 | AC_DEFUN([gl_STDIO_H_DEFAULTS], |
91 | [ | 181 | [ |
92 | GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF]) | ||
93 | GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE]) | ||
94 | GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN]) | ||
95 | GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) | ||
96 | GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC]) | ||
97 | GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS]) | ||
98 | GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN]) | ||
99 | GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF]) | ||
100 | GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX]) | ||
101 | GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE]) | ||
102 | GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC]) | ||
103 | GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS]) | ||
104 | GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD]) | ||
105 | GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN]) | ||
106 | GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF]) | ||
107 | GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) | ||
108 | GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) | ||
109 | GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) | ||
110 | GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) | ||
111 | GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE]) | ||
112 | GNULIB_GETC=0; AC_SUBST([GNULIB_GETC]) | ||
113 | GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR]) | ||
114 | GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM]) | ||
115 | GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE]) | ||
116 | GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF]) | ||
117 | GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX]) | ||
118 | GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE]) | ||
119 | GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR]) | ||
120 | GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN]) | ||
121 | GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF]) | ||
122 | GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX]) | ||
123 | GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC]) | ||
124 | GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR]) | ||
125 | GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS]) | ||
126 | GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE]) | ||
127 | GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME]) | ||
128 | GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT]) | ||
129 | GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF]) | ||
130 | GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) | ||
131 | GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) | ||
132 | GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING]) | ||
133 | GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE]) | ||
134 | GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE]) | ||
135 | GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) | ||
136 | GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF]) | ||
137 | GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF]) | ||
138 | GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF]) | ||
139 | GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF]) | ||
140 | GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX]) | ||
141 | GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF]) | ||
142 | GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX]) | ||
143 | GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF]) | ||
144 | GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) | ||
145 | dnl Assume proper GNU behavior unless another module says otherwise. | 182 | dnl Assume proper GNU behavior unless another module says otherwise. |
183 | HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL]) | ||
146 | HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) | 184 | HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) |
147 | HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) | 185 | HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) |
148 | HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) | 186 | HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) |