stdio.in.h revision 1.1.1.2 1 1.1 christos /* A GNU-like <stdio.h>.
2 1.1 christos
3 1.1.1.2 christos Copyright (C) 2004, 2007-2022 Free Software Foundation, Inc.
4 1.1 christos
5 1.1.1.2 christos This file is free software: you can redistribute it and/or modify
6 1.1.1.2 christos it under the terms of the GNU Lesser General Public License as
7 1.1.1.2 christos published by the Free Software Foundation; either version 2.1 of the
8 1.1.1.2 christos License, or (at your option) any later version.
9 1.1 christos
10 1.1.1.2 christos This file is distributed in the hope that it will be useful,
11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 1.1.1.2 christos GNU Lesser General Public License for more details.
14 1.1 christos
15 1.1.1.2 christos You should have received a copy of the GNU Lesser General Public License
16 1.1.1.2 christos along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 1.1 christos
18 1.1 christos #if __GNUC__ >= 3
19 1.1 christos @PRAGMA_SYSTEM_HEADER@
20 1.1 christos #endif
21 1.1 christos @PRAGMA_COLUMNS@
22 1.1 christos
23 1.1 christos #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
24 1.1 christos /* Special invocation convention:
25 1.1 christos - Inside glibc header files.
26 1.1 christos - On OSF/1 5.1 we have a sequence of nested includes
27 1.1 christos <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
28 1.1 christos <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
29 1.1 christos In this situation, the functions are not yet declared, therefore we cannot
30 1.1 christos provide the C++ aliases. */
31 1.1 christos
32 1.1 christos #@INCLUDE_NEXT@ @NEXT_STDIO_H@
33 1.1 christos
34 1.1 christos #else
35 1.1 christos /* Normal invocation convention. */
36 1.1 christos
37 1.1 christos #ifndef _@GUARD_PREFIX@_STDIO_H
38 1.1 christos
39 1.1 christos #define _GL_ALREADY_INCLUDING_STDIO_H
40 1.1 christos
41 1.1 christos /* The include_next requires a split double-inclusion guard. */
42 1.1 christos #@INCLUDE_NEXT@ @NEXT_STDIO_H@
43 1.1 christos
44 1.1 christos #undef _GL_ALREADY_INCLUDING_STDIO_H
45 1.1 christos
46 1.1 christos #ifndef _@GUARD_PREFIX@_STDIO_H
47 1.1 christos #define _@GUARD_PREFIX@_STDIO_H
48 1.1 christos
49 1.1 christos /* Get va_list. Needed on many systems, including glibc 2.8. */
50 1.1 christos #include <stdarg.h>
51 1.1 christos
52 1.1 christos #include <stddef.h>
53 1.1 christos
54 1.1 christos /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
55 1.1 christos and eglibc 2.11.2.
56 1.1 christos May also define off_t to a 64-bit type on native Windows. */
57 1.1 christos #include <sys/types.h>
58 1.1 christos
59 1.1.1.2 christos /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
60 1.1.1.2 christos /* But in any case avoid namespace pollution on glibc systems. */
61 1.1.1.2 christos #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
62 1.1.1.2 christos && ! defined __GLIBC__
63 1.1.1.2 christos # include <unistd.h>
64 1.1.1.2 christos #endif
65 1.1.1.2 christos
66 1.1.1.2 christos /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
67 1.1.1.2 christos /* But in any case avoid namespace pollution on glibc systems. */
68 1.1.1.2 christos #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
69 1.1.1.2 christos && ! defined __GLIBC__
70 1.1.1.2 christos # include <sys/stat.h>
71 1.1.1.2 christos #endif
72 1.1.1.2 christos
73 1.1.1.2 christos /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
74 1.1.1.2 christos it before we #define perror rpl_perror. */
75 1.1.1.2 christos /* But in any case avoid namespace pollution on glibc systems. */
76 1.1.1.2 christos #if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
77 1.1.1.2 christos && (defined _WIN32 && ! defined __CYGWIN__) \
78 1.1.1.2 christos && ! defined __GLIBC__
79 1.1.1.2 christos # include <stdlib.h>
80 1.1.1.2 christos #endif
81 1.1.1.2 christos
82 1.1.1.2 christos /* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
83 1.1.1.2 christos it before we #define remove rpl_remove. */
84 1.1.1.2 christos /* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
85 1.1.1.2 christos it before we #define rename rpl_rename. */
86 1.1.1.2 christos /* But in any case avoid namespace pollution on glibc systems. */
87 1.1.1.2 christos #if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
88 1.1.1.2 christos && (defined _WIN32 && ! defined __CYGWIN__) \
89 1.1.1.2 christos && ! defined __GLIBC__
90 1.1.1.2 christos # include <io.h>
91 1.1.1.2 christos #endif
92 1.1.1.2 christos
93 1.1.1.2 christos
94 1.1.1.2 christos /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
95 1.1.1.2 christos that can be freed by passing them as the Ith argument to the
96 1.1.1.2 christos function F. */
97 1.1.1.2 christos #ifndef _GL_ATTRIBUTE_DEALLOC
98 1.1.1.2 christos # if __GNUC__ >= 11
99 1.1.1.2 christos # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
100 1.1.1.2 christos # else
101 1.1.1.2 christos # define _GL_ATTRIBUTE_DEALLOC(f, i)
102 1.1.1.2 christos # endif
103 1.1.1.2 christos #endif
104 1.1.1.2 christos
105 1.1 christos /* The __attribute__ feature is available in gcc versions 2.5 and later.
106 1.1 christos The __-protected variants of the attributes 'format' and 'printf' are
107 1.1 christos accepted by gcc versions 2.6.4 (effectively 2.7) and later.
108 1.1 christos We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
109 1.1 christos gnulib and libintl do '#define printf __printf__' when they override
110 1.1 christos the 'printf' function. */
111 1.1 christos #ifndef _GL_ATTRIBUTE_FORMAT
112 1.1.1.2 christos # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
113 1.1 christos # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
114 1.1 christos # else
115 1.1 christos # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
116 1.1 christos # endif
117 1.1 christos #endif
118 1.1 christos
119 1.1.1.2 christos /* An __attribute__ __format__ specifier for a function that takes a format
120 1.1.1.2 christos string and arguments, where the format string directives are the ones
121 1.1.1.2 christos standardized by ISO C99 and POSIX.
122 1.1.1.2 christos _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
123 1.1.1.2 christos /* __gnu_printf__ is supported in GCC >= 4.4. */
124 1.1 christos #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
125 1.1.1.2 christos # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
126 1.1 christos #else
127 1.1.1.2 christos # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
128 1.1 christos #endif
129 1.1 christos
130 1.1.1.2 christos /* An __attribute__ __format__ specifier for a function that takes a format
131 1.1.1.2 christos string and arguments, where the format string directives are the ones of the
132 1.1.1.2 christos system printf(), rather than the ones standardized by ISO C99 and POSIX.
133 1.1.1.2 christos _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */
134 1.1.1.2 christos /* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
135 1.1.1.2 christos the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
136 1.1.1.2 christos whether this change is effective. On older mingw, it is not. */
137 1.1 christos #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
138 1.1.1.2 christos # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
139 1.1 christos #else
140 1.1.1.2 christos # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
141 1.1 christos #endif
142 1.1 christos
143 1.1.1.2 christos /* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
144 1.1.1.2 christos indicates to GCC that the function takes a format string and arguments,
145 1.1.1.2 christos where the format string directives are the ones standardized by ISO C99
146 1.1.1.2 christos and POSIX. */
147 1.1.1.2 christos #define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
148 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
149 1.1.1.2 christos
150 1.1.1.2 christos /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
151 1.1.1.2 christos except that it indicates to GCC that the supported format string directives
152 1.1.1.2 christos are the ones of the system printf(), rather than the ones standardized by
153 1.1.1.2 christos ISO C99 and POSIX. */
154 1.1.1.2 christos #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
155 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
156 1.1.1.2 christos
157 1.1 christos /* _GL_ATTRIBUTE_FORMAT_SCANF
158 1.1 christos indicates to GCC that the function takes a format string and arguments,
159 1.1 christos where the format string directives are the ones standardized by ISO C99
160 1.1 christos and POSIX. */
161 1.1 christos #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
162 1.1 christos # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
163 1.1 christos _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
164 1.1 christos #else
165 1.1 christos # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
166 1.1 christos _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
167 1.1 christos #endif
168 1.1 christos
169 1.1 christos /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
170 1.1 christos except that it indicates to GCC that the supported format string directives
171 1.1 christos are the ones of the system scanf(), rather than the ones standardized by
172 1.1 christos ISO C99 and POSIX. */
173 1.1 christos #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
174 1.1 christos _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
175 1.1 christos
176 1.1 christos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
177 1.1 christos
178 1.1 christos /* The definition of _GL_ARG_NONNULL is copied here. */
179 1.1 christos
180 1.1 christos /* The definition of _GL_WARN_ON_USE is copied here. */
181 1.1 christos
182 1.1 christos /* Macros for stringification. */
183 1.1 christos #define _GL_STDIO_STRINGIZE(token) #token
184 1.1 christos #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
185 1.1 christos
186 1.1 christos /* When also using extern inline, suppress the use of static inline in
187 1.1 christos standard headers of problematic Apple configurations, as Libc at
188 1.1 christos least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
189 1.1 christos <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
190 1.1 christos Perhaps Apple will fix this some day. */
191 1.1 christos #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
192 1.1 christos && defined __GNUC__ && defined __STDC__)
193 1.1 christos # undef putc_unlocked
194 1.1 christos #endif
195 1.1 christos
196 1.1 christos #if @GNULIB_DPRINTF@
197 1.1 christos # if @REPLACE_DPRINTF@
198 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
199 1.1 christos # define dprintf rpl_dprintf
200 1.1 christos # endif
201 1.1 christos _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
202 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
203 1.1 christos _GL_ARG_NONNULL ((2)));
204 1.1 christos _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
205 1.1 christos # else
206 1.1 christos # if !@HAVE_DPRINTF@
207 1.1 christos _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
208 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
209 1.1 christos _GL_ARG_NONNULL ((2)));
210 1.1 christos # endif
211 1.1 christos _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
212 1.1 christos # endif
213 1.1 christos _GL_CXXALIASWARN (dprintf);
214 1.1 christos #elif defined GNULIB_POSIXCHECK
215 1.1 christos # undef dprintf
216 1.1 christos # if HAVE_RAW_DECL_DPRINTF
217 1.1 christos _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
218 1.1 christos "use gnulib module dprintf for portability");
219 1.1 christos # endif
220 1.1 christos #endif
221 1.1 christos
222 1.1 christos #if @GNULIB_FCLOSE@
223 1.1 christos /* Close STREAM and its underlying file descriptor. */
224 1.1 christos # if @REPLACE_FCLOSE@
225 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
226 1.1 christos # define fclose rpl_fclose
227 1.1 christos # endif
228 1.1 christos _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
229 1.1 christos _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
230 1.1 christos # else
231 1.1 christos _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
232 1.1 christos # endif
233 1.1 christos # if __GLIBC__ >= 2
234 1.1 christos _GL_CXXALIASWARN (fclose);
235 1.1 christos # endif
236 1.1 christos #elif defined GNULIB_POSIXCHECK
237 1.1 christos # undef fclose
238 1.1 christos /* Assume fclose is always declared. */
239 1.1 christos _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
240 1.1 christos "use gnulib module fclose for portable POSIX compliance");
241 1.1 christos #endif
242 1.1 christos
243 1.1.1.2 christos #if @GNULIB_MDA_FCLOSEALL@
244 1.1.1.2 christos /* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
245 1.1.1.2 christos not required. In C++ with GNULIB_NAMESPACE, avoid differences between
246 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
247 1.1.1.2 christos it. */
248 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
249 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
250 1.1.1.2 christos # undef fcloseall
251 1.1.1.2 christos # define fcloseall _fcloseall
252 1.1.1.2 christos # endif
253 1.1.1.2 christos _GL_CXXALIAS_MDA (fcloseall, int, (void));
254 1.1.1.2 christos # else
255 1.1.1.2 christos # if @HAVE_DECL_FCLOSEALL@
256 1.1.1.2 christos # if defined __FreeBSD__ || defined __DragonFly__
257 1.1.1.2 christos _GL_CXXALIAS_SYS (fcloseall, void, (void));
258 1.1.1.2 christos # else
259 1.1.1.2 christos _GL_CXXALIAS_SYS (fcloseall, int, (void));
260 1.1.1.2 christos # endif
261 1.1.1.2 christos # endif
262 1.1.1.2 christos # endif
263 1.1.1.2 christos # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@
264 1.1.1.2 christos _GL_CXXALIASWARN (fcloseall);
265 1.1.1.2 christos # endif
266 1.1.1.2 christos #endif
267 1.1.1.2 christos
268 1.1 christos #if @GNULIB_FDOPEN@
269 1.1 christos # if @REPLACE_FDOPEN@
270 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
271 1.1 christos # undef fdopen
272 1.1 christos # define fdopen rpl_fdopen
273 1.1 christos # endif
274 1.1.1.2 christos _GL_FUNCDECL_RPL (fdopen, FILE *,
275 1.1.1.2 christos (int fd, const char *mode)
276 1.1.1.2 christos _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
277 1.1 christos _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
278 1.1.1.2 christos # elif defined _WIN32 && !defined __CYGWIN__
279 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280 1.1.1.2 christos # undef fdopen
281 1.1.1.2 christos # define fdopen _fdopen
282 1.1.1.2 christos # endif
283 1.1.1.2 christos _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
284 1.1 christos # else
285 1.1.1.2 christos # if __GNUC__ >= 11
286 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
287 1.1.1.2 christos _GL_FUNCDECL_SYS (fdopen, FILE *,
288 1.1.1.2 christos (int fd, const char *mode)
289 1.1.1.2 christos _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
290 1.1.1.2 christos # endif
291 1.1 christos _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
292 1.1 christos # endif
293 1.1 christos _GL_CXXALIASWARN (fdopen);
294 1.1.1.2 christos #else
295 1.1.1.2 christos # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
296 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
297 1.1.1.2 christos _GL_FUNCDECL_SYS (fdopen, FILE *,
298 1.1.1.2 christos (int fd, const char *mode)
299 1.1.1.2 christos _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
300 1.1.1.2 christos # endif
301 1.1.1.2 christos # if defined GNULIB_POSIXCHECK
302 1.1.1.2 christos # undef fdopen
303 1.1 christos /* Assume fdopen is always declared. */
304 1.1 christos _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
305 1.1 christos "use gnulib module fdopen for portability");
306 1.1.1.2 christos # elif @GNULIB_MDA_FDOPEN@
307 1.1.1.2 christos /* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
308 1.1.1.2 christos required. In C++ with GNULIB_NAMESPACE, avoid differences between
309 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::fdopen always. */
310 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
311 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312 1.1.1.2 christos # undef fdopen
313 1.1.1.2 christos # define fdopen _fdopen
314 1.1.1.2 christos # endif
315 1.1.1.2 christos _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
316 1.1.1.2 christos # else
317 1.1.1.2 christos _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
318 1.1.1.2 christos # endif
319 1.1.1.2 christos _GL_CXXALIASWARN (fdopen);
320 1.1.1.2 christos # endif
321 1.1 christos #endif
322 1.1 christos
323 1.1 christos #if @GNULIB_FFLUSH@
324 1.1 christos /* Flush all pending data on STREAM according to POSIX rules. Both
325 1.1 christos output and seekable input streams are supported.
326 1.1 christos Note! LOSS OF DATA can occur if fflush is applied on an input stream
327 1.1 christos that is _not_seekable_ or on an update stream that is _not_seekable_
328 1.1 christos and in which the most recent operation was input. Seekability can
329 1.1 christos be tested with lseek(fileno(fp),0,SEEK_CUR). */
330 1.1 christos # if @REPLACE_FFLUSH@
331 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
332 1.1 christos # define fflush rpl_fflush
333 1.1 christos # endif
334 1.1 christos _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
335 1.1 christos _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
336 1.1 christos # else
337 1.1 christos _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
338 1.1 christos # endif
339 1.1 christos # if __GLIBC__ >= 2
340 1.1 christos _GL_CXXALIASWARN (fflush);
341 1.1 christos # endif
342 1.1 christos #elif defined GNULIB_POSIXCHECK
343 1.1 christos # undef fflush
344 1.1 christos /* Assume fflush is always declared. */
345 1.1 christos _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
346 1.1 christos "use gnulib module fflush for portable POSIX compliance");
347 1.1 christos #endif
348 1.1 christos
349 1.1 christos #if @GNULIB_FGETC@
350 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
351 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
352 1.1 christos # undef fgetc
353 1.1 christos # define fgetc rpl_fgetc
354 1.1 christos # endif
355 1.1 christos _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
356 1.1 christos _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
357 1.1 christos # else
358 1.1 christos _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
359 1.1 christos # endif
360 1.1 christos # if __GLIBC__ >= 2
361 1.1 christos _GL_CXXALIASWARN (fgetc);
362 1.1 christos # endif
363 1.1 christos #endif
364 1.1 christos
365 1.1 christos #if @GNULIB_FGETS@
366 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
367 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
368 1.1 christos # undef fgets
369 1.1 christos # define fgets rpl_fgets
370 1.1 christos # endif
371 1.1 christos _GL_FUNCDECL_RPL (fgets, char *,
372 1.1 christos (char *restrict s, int n, FILE *restrict stream)
373 1.1 christos _GL_ARG_NONNULL ((1, 3)));
374 1.1 christos _GL_CXXALIAS_RPL (fgets, char *,
375 1.1 christos (char *restrict s, int n, FILE *restrict stream));
376 1.1 christos # else
377 1.1 christos _GL_CXXALIAS_SYS (fgets, char *,
378 1.1 christos (char *restrict s, int n, FILE *restrict stream));
379 1.1 christos # endif
380 1.1 christos # if __GLIBC__ >= 2
381 1.1 christos _GL_CXXALIASWARN (fgets);
382 1.1 christos # endif
383 1.1 christos #endif
384 1.1 christos
385 1.1.1.2 christos #if @GNULIB_MDA_FILENO@
386 1.1.1.2 christos /* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
387 1.1.1.2 christos required. In C++ with GNULIB_NAMESPACE, avoid differences between
388 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::fileno always. */
389 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
390 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
391 1.1.1.2 christos # undef fileno
392 1.1.1.2 christos # define fileno _fileno
393 1.1.1.2 christos # endif
394 1.1.1.2 christos _GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream));
395 1.1.1.2 christos # else
396 1.1.1.2 christos _GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream));
397 1.1.1.2 christos # endif
398 1.1.1.2 christos _GL_CXXALIASWARN (fileno);
399 1.1.1.2 christos #endif
400 1.1.1.2 christos
401 1.1 christos #if @GNULIB_FOPEN@
402 1.1.1.2 christos # if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
403 1.1.1.2 christos || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
404 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405 1.1 christos # undef fopen
406 1.1 christos # define fopen rpl_fopen
407 1.1 christos # endif
408 1.1 christos _GL_FUNCDECL_RPL (fopen, FILE *,
409 1.1 christos (const char *restrict filename, const char *restrict mode)
410 1.1.1.2 christos _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
411 1.1 christos _GL_CXXALIAS_RPL (fopen, FILE *,
412 1.1 christos (const char *restrict filename, const char *restrict mode));
413 1.1 christos # else
414 1.1.1.2 christos # if __GNUC__ >= 11
415 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
416 1.1.1.2 christos _GL_FUNCDECL_SYS (fopen, FILE *,
417 1.1.1.2 christos (const char *restrict filename, const char *restrict mode)
418 1.1.1.2 christos _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
419 1.1.1.2 christos # endif
420 1.1 christos _GL_CXXALIAS_SYS (fopen, FILE *,
421 1.1 christos (const char *restrict filename, const char *restrict mode));
422 1.1 christos # endif
423 1.1 christos # if __GLIBC__ >= 2
424 1.1 christos _GL_CXXALIASWARN (fopen);
425 1.1 christos # endif
426 1.1.1.2 christos #else
427 1.1.1.2 christos # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
428 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
429 1.1.1.2 christos _GL_FUNCDECL_SYS (fopen, FILE *,
430 1.1.1.2 christos (const char *restrict filename, const char *restrict mode)
431 1.1.1.2 christos _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
432 1.1.1.2 christos # endif
433 1.1.1.2 christos # if defined GNULIB_POSIXCHECK
434 1.1.1.2 christos # undef fopen
435 1.1 christos /* Assume fopen is always declared. */
436 1.1 christos _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
437 1.1 christos "use gnulib module fopen for portability");
438 1.1.1.2 christos # endif
439 1.1 christos #endif
440 1.1 christos
441 1.1 christos #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
442 1.1 christos # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
443 1.1 christos || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
444 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445 1.1 christos # define fprintf rpl_fprintf
446 1.1 christos # endif
447 1.1 christos # define GNULIB_overrides_fprintf 1
448 1.1 christos # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
449 1.1 christos _GL_FUNCDECL_RPL (fprintf, int,
450 1.1 christos (FILE *restrict fp, const char *restrict format, ...)
451 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
452 1.1 christos _GL_ARG_NONNULL ((1, 2)));
453 1.1 christos # else
454 1.1 christos _GL_FUNCDECL_RPL (fprintf, int,
455 1.1 christos (FILE *restrict fp, const char *restrict format, ...)
456 1.1 christos _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
457 1.1 christos _GL_ARG_NONNULL ((1, 2)));
458 1.1 christos # endif
459 1.1 christos _GL_CXXALIAS_RPL (fprintf, int,
460 1.1 christos (FILE *restrict fp, const char *restrict format, ...));
461 1.1 christos # else
462 1.1 christos _GL_CXXALIAS_SYS (fprintf, int,
463 1.1 christos (FILE *restrict fp, const char *restrict format, ...));
464 1.1 christos # endif
465 1.1 christos # if __GLIBC__ >= 2
466 1.1 christos _GL_CXXALIASWARN (fprintf);
467 1.1 christos # endif
468 1.1 christos #endif
469 1.1 christos #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
470 1.1 christos # if !GNULIB_overrides_fprintf
471 1.1 christos # undef fprintf
472 1.1 christos # endif
473 1.1 christos /* Assume fprintf is always declared. */
474 1.1 christos _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
475 1.1 christos "use gnulib module fprintf-posix for portable "
476 1.1 christos "POSIX compliance");
477 1.1 christos #endif
478 1.1 christos
479 1.1 christos #if @GNULIB_FPURGE@
480 1.1 christos /* Discard all pending buffered I/O data on STREAM.
481 1.1 christos STREAM must not be wide-character oriented.
482 1.1 christos When discarding pending output, the file position is set back to where it
483 1.1 christos was before the write calls. When discarding pending input, the file
484 1.1 christos position is advanced to match the end of the previously read input.
485 1.1 christos Return 0 if successful. Upon error, return -1 and set errno. */
486 1.1 christos # if @REPLACE_FPURGE@
487 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
488 1.1 christos # define fpurge rpl_fpurge
489 1.1 christos # endif
490 1.1 christos _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
491 1.1 christos _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
492 1.1 christos # else
493 1.1 christos # if !@HAVE_DECL_FPURGE@
494 1.1 christos _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
495 1.1 christos # endif
496 1.1 christos _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
497 1.1 christos # endif
498 1.1 christos _GL_CXXALIASWARN (fpurge);
499 1.1 christos #elif defined GNULIB_POSIXCHECK
500 1.1 christos # undef fpurge
501 1.1 christos # if HAVE_RAW_DECL_FPURGE
502 1.1 christos _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
503 1.1 christos "use gnulib module fpurge for portability");
504 1.1 christos # endif
505 1.1 christos #endif
506 1.1 christos
507 1.1 christos #if @GNULIB_FPUTC@
508 1.1 christos # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
509 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
510 1.1 christos # undef fputc
511 1.1 christos # define fputc rpl_fputc
512 1.1 christos # endif
513 1.1 christos _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
514 1.1 christos _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
515 1.1 christos # else
516 1.1 christos _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
517 1.1 christos # endif
518 1.1 christos # if __GLIBC__ >= 2
519 1.1 christos _GL_CXXALIASWARN (fputc);
520 1.1 christos # endif
521 1.1 christos #endif
522 1.1 christos
523 1.1 christos #if @GNULIB_FPUTS@
524 1.1 christos # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
525 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
526 1.1 christos # undef fputs
527 1.1 christos # define fputs rpl_fputs
528 1.1 christos # endif
529 1.1 christos _GL_FUNCDECL_RPL (fputs, int,
530 1.1 christos (const char *restrict string, FILE *restrict stream)
531 1.1 christos _GL_ARG_NONNULL ((1, 2)));
532 1.1 christos _GL_CXXALIAS_RPL (fputs, int,
533 1.1 christos (const char *restrict string, FILE *restrict stream));
534 1.1 christos # else
535 1.1 christos _GL_CXXALIAS_SYS (fputs, int,
536 1.1 christos (const char *restrict string, FILE *restrict stream));
537 1.1 christos # endif
538 1.1 christos # if __GLIBC__ >= 2
539 1.1 christos _GL_CXXALIASWARN (fputs);
540 1.1 christos # endif
541 1.1 christos #endif
542 1.1 christos
543 1.1 christos #if @GNULIB_FREAD@
544 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
545 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
546 1.1 christos # undef fread
547 1.1 christos # define fread rpl_fread
548 1.1 christos # endif
549 1.1 christos _GL_FUNCDECL_RPL (fread, size_t,
550 1.1 christos (void *restrict ptr, size_t s, size_t n,
551 1.1 christos FILE *restrict stream)
552 1.1 christos _GL_ARG_NONNULL ((4)));
553 1.1 christos _GL_CXXALIAS_RPL (fread, size_t,
554 1.1 christos (void *restrict ptr, size_t s, size_t n,
555 1.1 christos FILE *restrict stream));
556 1.1 christos # else
557 1.1 christos _GL_CXXALIAS_SYS (fread, size_t,
558 1.1 christos (void *restrict ptr, size_t s, size_t n,
559 1.1 christos FILE *restrict stream));
560 1.1 christos # endif
561 1.1 christos # if __GLIBC__ >= 2
562 1.1 christos _GL_CXXALIASWARN (fread);
563 1.1 christos # endif
564 1.1 christos #endif
565 1.1 christos
566 1.1 christos #if @GNULIB_FREOPEN@
567 1.1 christos # if @REPLACE_FREOPEN@
568 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569 1.1 christos # undef freopen
570 1.1 christos # define freopen rpl_freopen
571 1.1 christos # endif
572 1.1 christos _GL_FUNCDECL_RPL (freopen, FILE *,
573 1.1 christos (const char *restrict filename, const char *restrict mode,
574 1.1 christos FILE *restrict stream)
575 1.1 christos _GL_ARG_NONNULL ((2, 3)));
576 1.1 christos _GL_CXXALIAS_RPL (freopen, FILE *,
577 1.1 christos (const char *restrict filename, const char *restrict mode,
578 1.1 christos FILE *restrict stream));
579 1.1 christos # else
580 1.1 christos _GL_CXXALIAS_SYS (freopen, FILE *,
581 1.1 christos (const char *restrict filename, const char *restrict mode,
582 1.1 christos FILE *restrict stream));
583 1.1 christos # endif
584 1.1 christos # if __GLIBC__ >= 2
585 1.1 christos _GL_CXXALIASWARN (freopen);
586 1.1 christos # endif
587 1.1 christos #elif defined GNULIB_POSIXCHECK
588 1.1 christos # undef freopen
589 1.1 christos /* Assume freopen is always declared. */
590 1.1 christos _GL_WARN_ON_USE (freopen,
591 1.1 christos "freopen on native Windows platforms is not POSIX compliant - "
592 1.1 christos "use gnulib module freopen for portability");
593 1.1 christos #endif
594 1.1 christos
595 1.1 christos #if @GNULIB_FSCANF@
596 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
597 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
598 1.1 christos # undef fscanf
599 1.1 christos # define fscanf rpl_fscanf
600 1.1 christos # endif
601 1.1 christos _GL_FUNCDECL_RPL (fscanf, int,
602 1.1 christos (FILE *restrict stream, const char *restrict format, ...)
603 1.1 christos _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
604 1.1 christos _GL_ARG_NONNULL ((1, 2)));
605 1.1 christos _GL_CXXALIAS_RPL (fscanf, int,
606 1.1 christos (FILE *restrict stream, const char *restrict format, ...));
607 1.1 christos # else
608 1.1 christos _GL_CXXALIAS_SYS (fscanf, int,
609 1.1 christos (FILE *restrict stream, const char *restrict format, ...));
610 1.1 christos # endif
611 1.1 christos # if __GLIBC__ >= 2
612 1.1 christos _GL_CXXALIASWARN (fscanf);
613 1.1 christos # endif
614 1.1 christos #endif
615 1.1 christos
616 1.1 christos
617 1.1 christos /* Set up the following warnings, based on which modules are in use.
618 1.1 christos GNU Coding Standards discourage the use of fseek, since it imposes
619 1.1 christos an arbitrary limitation on some 32-bit hosts. Remember that the
620 1.1 christos fseek module depends on the fseeko module, so we only have three
621 1.1 christos cases to consider:
622 1.1 christos
623 1.1 christos 1. The developer is not using either module. Issue a warning under
624 1.1 christos GNULIB_POSIXCHECK for both functions, to remind them that both
625 1.1 christos functions have bugs on some systems. _GL_NO_LARGE_FILES has no
626 1.1 christos impact on this warning.
627 1.1 christos
628 1.1 christos 2. The developer is using both modules. They may be unaware of the
629 1.1 christos arbitrary limitations of fseek, so issue a warning under
630 1.1 christos GNULIB_POSIXCHECK. On the other hand, they may be using both
631 1.1 christos modules intentionally, so the developer can define
632 1.1 christos _GL_NO_LARGE_FILES in the compilation units where the use of fseek
633 1.1 christos is safe, to silence the warning.
634 1.1 christos
635 1.1 christos 3. The developer is using the fseeko module, but not fseek. Gnulib
636 1.1 christos guarantees that fseek will still work around platform bugs in that
637 1.1 christos case, but we presume that the developer is aware of the pitfalls of
638 1.1 christos fseek and was trying to avoid it, so issue a warning even when
639 1.1 christos GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
640 1.1 christos defined to silence the warning in particular compilation units.
641 1.1 christos In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
642 1.1 christos fseek gets defined as a macro, it is recommended that the developer
643 1.1 christos uses the fseek module, even if he is not calling the fseek function.
644 1.1 christos
645 1.1 christos Most gnulib clients that perform stream operations should fall into
646 1.1 christos category 3. */
647 1.1 christos
648 1.1 christos #if @GNULIB_FSEEK@
649 1.1 christos # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
650 1.1 christos # define _GL_FSEEK_WARN /* Category 2, above. */
651 1.1 christos # undef fseek
652 1.1 christos # endif
653 1.1 christos # if @REPLACE_FSEEK@
654 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
655 1.1 christos # undef fseek
656 1.1 christos # define fseek rpl_fseek
657 1.1 christos # endif
658 1.1 christos _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
659 1.1 christos _GL_ARG_NONNULL ((1)));
660 1.1 christos _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
661 1.1 christos # else
662 1.1 christos _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
663 1.1 christos # endif
664 1.1 christos # if __GLIBC__ >= 2
665 1.1 christos _GL_CXXALIASWARN (fseek);
666 1.1 christos # endif
667 1.1 christos #endif
668 1.1 christos
669 1.1 christos #if @GNULIB_FSEEKO@
670 1.1 christos # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
671 1.1 christos # define _GL_FSEEK_WARN /* Category 3, above. */
672 1.1 christos # undef fseek
673 1.1 christos # endif
674 1.1 christos # if @REPLACE_FSEEKO@
675 1.1 christos /* Provide an fseeko function that is aware of a preceding fflush(), and which
676 1.1 christos detects pipes. */
677 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
678 1.1 christos # undef fseeko
679 1.1 christos # define fseeko rpl_fseeko
680 1.1 christos # endif
681 1.1 christos _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
682 1.1 christos _GL_ARG_NONNULL ((1)));
683 1.1 christos _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
684 1.1 christos # else
685 1.1 christos # if ! @HAVE_DECL_FSEEKO@
686 1.1 christos _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
687 1.1 christos _GL_ARG_NONNULL ((1)));
688 1.1 christos # endif
689 1.1 christos _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
690 1.1 christos # endif
691 1.1 christos _GL_CXXALIASWARN (fseeko);
692 1.1 christos #elif defined GNULIB_POSIXCHECK
693 1.1 christos # define _GL_FSEEK_WARN /* Category 1, above. */
694 1.1 christos # undef fseek
695 1.1 christos # undef fseeko
696 1.1 christos # if HAVE_RAW_DECL_FSEEKO
697 1.1 christos _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
698 1.1 christos "use gnulib module fseeko for portability");
699 1.1 christos # endif
700 1.1 christos #endif
701 1.1 christos
702 1.1 christos #ifdef _GL_FSEEK_WARN
703 1.1 christos # undef _GL_FSEEK_WARN
704 1.1 christos /* Here, either fseek is undefined (but C89 guarantees that it is
705 1.1 christos declared), or it is defined as rpl_fseek (declared above). */
706 1.1 christos _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
707 1.1 christos "on 32-bit platforms - "
708 1.1 christos "use fseeko function for handling of large files");
709 1.1 christos #endif
710 1.1 christos
711 1.1 christos
712 1.1 christos /* ftell, ftello. See the comments on fseek/fseeko. */
713 1.1 christos
714 1.1 christos #if @GNULIB_FTELL@
715 1.1 christos # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
716 1.1 christos # define _GL_FTELL_WARN /* Category 2, above. */
717 1.1 christos # undef ftell
718 1.1 christos # endif
719 1.1 christos # if @REPLACE_FTELL@
720 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
721 1.1 christos # undef ftell
722 1.1 christos # define ftell rpl_ftell
723 1.1 christos # endif
724 1.1 christos _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
725 1.1 christos _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
726 1.1 christos # else
727 1.1 christos _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
728 1.1 christos # endif
729 1.1 christos # if __GLIBC__ >= 2
730 1.1 christos _GL_CXXALIASWARN (ftell);
731 1.1 christos # endif
732 1.1 christos #endif
733 1.1 christos
734 1.1 christos #if @GNULIB_FTELLO@
735 1.1 christos # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
736 1.1 christos # define _GL_FTELL_WARN /* Category 3, above. */
737 1.1 christos # undef ftell
738 1.1 christos # endif
739 1.1 christos # if @REPLACE_FTELLO@
740 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
741 1.1 christos # undef ftello
742 1.1 christos # define ftello rpl_ftello
743 1.1 christos # endif
744 1.1 christos _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
745 1.1 christos _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
746 1.1 christos # else
747 1.1 christos # if ! @HAVE_DECL_FTELLO@
748 1.1 christos _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
749 1.1 christos # endif
750 1.1 christos _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
751 1.1 christos # endif
752 1.1 christos _GL_CXXALIASWARN (ftello);
753 1.1 christos #elif defined GNULIB_POSIXCHECK
754 1.1 christos # define _GL_FTELL_WARN /* Category 1, above. */
755 1.1 christos # undef ftell
756 1.1 christos # undef ftello
757 1.1 christos # if HAVE_RAW_DECL_FTELLO
758 1.1 christos _GL_WARN_ON_USE (ftello, "ftello is unportable - "
759 1.1 christos "use gnulib module ftello for portability");
760 1.1 christos # endif
761 1.1 christos #endif
762 1.1 christos
763 1.1 christos #ifdef _GL_FTELL_WARN
764 1.1 christos # undef _GL_FTELL_WARN
765 1.1 christos /* Here, either ftell is undefined (but C89 guarantees that it is
766 1.1 christos declared), or it is defined as rpl_ftell (declared above). */
767 1.1 christos _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
768 1.1 christos "on 32-bit platforms - "
769 1.1 christos "use ftello function for handling of large files");
770 1.1 christos #endif
771 1.1 christos
772 1.1 christos
773 1.1 christos #if @GNULIB_FWRITE@
774 1.1 christos # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
775 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
776 1.1 christos # undef fwrite
777 1.1 christos # define fwrite rpl_fwrite
778 1.1 christos # endif
779 1.1 christos _GL_FUNCDECL_RPL (fwrite, size_t,
780 1.1 christos (const void *restrict ptr, size_t s, size_t n,
781 1.1 christos FILE *restrict stream)
782 1.1 christos _GL_ARG_NONNULL ((1, 4)));
783 1.1 christos _GL_CXXALIAS_RPL (fwrite, size_t,
784 1.1 christos (const void *restrict ptr, size_t s, size_t n,
785 1.1 christos FILE *restrict stream));
786 1.1 christos # else
787 1.1 christos _GL_CXXALIAS_SYS (fwrite, size_t,
788 1.1 christos (const void *restrict ptr, size_t s, size_t n,
789 1.1 christos FILE *restrict stream));
790 1.1 christos
791 1.1 christos /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
792 1.1 christos <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
793 1.1 christos which sometimes causes an unwanted diagnostic for fwrite calls.
794 1.1 christos This affects only function declaration attributes under certain
795 1.1 christos versions of gcc and clang, and is not needed for C++. */
796 1.1 christos # if (0 < __USE_FORTIFY_LEVEL \
797 1.1 christos && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
798 1.1 christos && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
799 1.1 christos && !defined __cplusplus)
800 1.1 christos # undef fwrite
801 1.1 christos # undef fwrite_unlocked
802 1.1 christos extern size_t __REDIRECT (rpl_fwrite,
803 1.1 christos (const void *__restrict, size_t, size_t,
804 1.1 christos FILE *__restrict),
805 1.1 christos fwrite);
806 1.1 christos extern size_t __REDIRECT (rpl_fwrite_unlocked,
807 1.1 christos (const void *__restrict, size_t, size_t,
808 1.1 christos FILE *__restrict),
809 1.1 christos fwrite_unlocked);
810 1.1 christos # define fwrite rpl_fwrite
811 1.1 christos # define fwrite_unlocked rpl_fwrite_unlocked
812 1.1 christos # endif
813 1.1 christos # endif
814 1.1 christos # if __GLIBC__ >= 2
815 1.1 christos _GL_CXXALIASWARN (fwrite);
816 1.1 christos # endif
817 1.1 christos #endif
818 1.1 christos
819 1.1 christos #if @GNULIB_GETC@
820 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
821 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
822 1.1 christos # undef getc
823 1.1 christos # define getc rpl_fgetc
824 1.1 christos # endif
825 1.1 christos _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
826 1.1 christos _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
827 1.1 christos # else
828 1.1 christos _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
829 1.1 christos # endif
830 1.1 christos # if __GLIBC__ >= 2
831 1.1 christos _GL_CXXALIASWARN (getc);
832 1.1 christos # endif
833 1.1 christos #endif
834 1.1 christos
835 1.1 christos #if @GNULIB_GETCHAR@
836 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
837 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
838 1.1 christos # undef getchar
839 1.1 christos # define getchar rpl_getchar
840 1.1 christos # endif
841 1.1 christos _GL_FUNCDECL_RPL (getchar, int, (void));
842 1.1 christos _GL_CXXALIAS_RPL (getchar, int, (void));
843 1.1 christos # else
844 1.1 christos _GL_CXXALIAS_SYS (getchar, int, (void));
845 1.1 christos # endif
846 1.1 christos # if __GLIBC__ >= 2
847 1.1 christos _GL_CXXALIASWARN (getchar);
848 1.1 christos # endif
849 1.1 christos #endif
850 1.1 christos
851 1.1 christos #if @GNULIB_GETDELIM@
852 1.1 christos /* Read input, up to (and including) the next occurrence of DELIMITER, from
853 1.1 christos STREAM, store it in *LINEPTR (and NUL-terminate it).
854 1.1 christos *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
855 1.1 christos bytes of space. It is realloc'd as necessary.
856 1.1 christos Return the number of bytes read and stored at *LINEPTR (not including the
857 1.1 christos NUL terminator), or -1 on error or EOF. */
858 1.1 christos # if @REPLACE_GETDELIM@
859 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
860 1.1 christos # undef getdelim
861 1.1 christos # define getdelim rpl_getdelim
862 1.1 christos # endif
863 1.1 christos _GL_FUNCDECL_RPL (getdelim, ssize_t,
864 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
865 1.1 christos int delimiter,
866 1.1 christos FILE *restrict stream)
867 1.1 christos _GL_ARG_NONNULL ((1, 2, 4)));
868 1.1 christos _GL_CXXALIAS_RPL (getdelim, ssize_t,
869 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
870 1.1 christos int delimiter,
871 1.1 christos FILE *restrict stream));
872 1.1 christos # else
873 1.1 christos # if !@HAVE_DECL_GETDELIM@
874 1.1 christos _GL_FUNCDECL_SYS (getdelim, ssize_t,
875 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
876 1.1 christos int delimiter,
877 1.1 christos FILE *restrict stream)
878 1.1 christos _GL_ARG_NONNULL ((1, 2, 4)));
879 1.1 christos # endif
880 1.1 christos _GL_CXXALIAS_SYS (getdelim, ssize_t,
881 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
882 1.1 christos int delimiter,
883 1.1 christos FILE *restrict stream));
884 1.1 christos # endif
885 1.1 christos _GL_CXXALIASWARN (getdelim);
886 1.1 christos #elif defined GNULIB_POSIXCHECK
887 1.1 christos # undef getdelim
888 1.1 christos # if HAVE_RAW_DECL_GETDELIM
889 1.1 christos _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
890 1.1 christos "use gnulib module getdelim for portability");
891 1.1 christos # endif
892 1.1 christos #endif
893 1.1 christos
894 1.1 christos #if @GNULIB_GETLINE@
895 1.1 christos /* Read a line, up to (and including) the next newline, from STREAM, store it
896 1.1 christos in *LINEPTR (and NUL-terminate it).
897 1.1 christos *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
898 1.1 christos bytes of space. It is realloc'd as necessary.
899 1.1 christos Return the number of bytes read and stored at *LINEPTR (not including the
900 1.1 christos NUL terminator), or -1 on error or EOF. */
901 1.1 christos # if @REPLACE_GETLINE@
902 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
903 1.1 christos # undef getline
904 1.1 christos # define getline rpl_getline
905 1.1 christos # endif
906 1.1 christos _GL_FUNCDECL_RPL (getline, ssize_t,
907 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
908 1.1 christos FILE *restrict stream)
909 1.1 christos _GL_ARG_NONNULL ((1, 2, 3)));
910 1.1 christos _GL_CXXALIAS_RPL (getline, ssize_t,
911 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
912 1.1 christos FILE *restrict stream));
913 1.1 christos # else
914 1.1 christos # if !@HAVE_DECL_GETLINE@
915 1.1 christos _GL_FUNCDECL_SYS (getline, ssize_t,
916 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
917 1.1 christos FILE *restrict stream)
918 1.1 christos _GL_ARG_NONNULL ((1, 2, 3)));
919 1.1 christos # endif
920 1.1 christos _GL_CXXALIAS_SYS (getline, ssize_t,
921 1.1 christos (char **restrict lineptr, size_t *restrict linesize,
922 1.1 christos FILE *restrict stream));
923 1.1 christos # endif
924 1.1 christos # if @HAVE_DECL_GETLINE@
925 1.1 christos _GL_CXXALIASWARN (getline);
926 1.1 christos # endif
927 1.1 christos #elif defined GNULIB_POSIXCHECK
928 1.1 christos # undef getline
929 1.1 christos # if HAVE_RAW_DECL_GETLINE
930 1.1 christos _GL_WARN_ON_USE (getline, "getline is unportable - "
931 1.1 christos "use gnulib module getline for portability");
932 1.1 christos # endif
933 1.1 christos #endif
934 1.1 christos
935 1.1 christos /* It is very rare that the developer ever has full control of stdin,
936 1.1 christos so any use of gets warrants an unconditional warning; besides, C11
937 1.1 christos removed it. */
938 1.1 christos #undef gets
939 1.1 christos #if HAVE_RAW_DECL_GETS && !defined __cplusplus
940 1.1 christos _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
941 1.1 christos #endif
942 1.1 christos
943 1.1.1.2 christos #if @GNULIB_MDA_GETW@
944 1.1.1.2 christos /* On native Windows, map 'getw' to '_getw', so that -loldnames is not
945 1.1.1.2 christos required. In C++ with GNULIB_NAMESPACE, avoid differences between
946 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::getw always. */
947 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
948 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949 1.1.1.2 christos # undef getw
950 1.1.1.2 christos # define getw _getw
951 1.1.1.2 christos # endif
952 1.1.1.2 christos _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
953 1.1.1.2 christos # else
954 1.1.1.2 christos _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
955 1.1.1.2 christos # endif
956 1.1.1.2 christos _GL_CXXALIASWARN (getw);
957 1.1.1.2 christos #endif
958 1.1.1.2 christos
959 1.1 christos #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
960 1.1 christos struct obstack;
961 1.1 christos /* Grow an obstack with formatted output. Return the number of
962 1.1 christos bytes added to OBS. No trailing nul byte is added, and the
963 1.1 christos object should be closed with obstack_finish before use. Upon
964 1.1 christos memory allocation error, call obstack_alloc_failed_handler. Upon
965 1.1 christos other error, return -1. */
966 1.1 christos # if @REPLACE_OBSTACK_PRINTF@
967 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968 1.1 christos # define obstack_printf rpl_obstack_printf
969 1.1 christos # endif
970 1.1 christos _GL_FUNCDECL_RPL (obstack_printf, int,
971 1.1 christos (struct obstack *obs, const char *format, ...)
972 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
973 1.1 christos _GL_ARG_NONNULL ((1, 2)));
974 1.1 christos _GL_CXXALIAS_RPL (obstack_printf, int,
975 1.1 christos (struct obstack *obs, const char *format, ...));
976 1.1 christos # else
977 1.1 christos # if !@HAVE_DECL_OBSTACK_PRINTF@
978 1.1 christos _GL_FUNCDECL_SYS (obstack_printf, int,
979 1.1 christos (struct obstack *obs, const char *format, ...)
980 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
981 1.1 christos _GL_ARG_NONNULL ((1, 2)));
982 1.1 christos # endif
983 1.1 christos _GL_CXXALIAS_SYS (obstack_printf, int,
984 1.1 christos (struct obstack *obs, const char *format, ...));
985 1.1 christos # endif
986 1.1 christos _GL_CXXALIASWARN (obstack_printf);
987 1.1 christos # if @REPLACE_OBSTACK_PRINTF@
988 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
989 1.1 christos # define obstack_vprintf rpl_obstack_vprintf
990 1.1 christos # endif
991 1.1 christos _GL_FUNCDECL_RPL (obstack_vprintf, int,
992 1.1 christos (struct obstack *obs, const char *format, va_list args)
993 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
994 1.1 christos _GL_ARG_NONNULL ((1, 2)));
995 1.1 christos _GL_CXXALIAS_RPL (obstack_vprintf, int,
996 1.1 christos (struct obstack *obs, const char *format, va_list args));
997 1.1 christos # else
998 1.1 christos # if !@HAVE_DECL_OBSTACK_PRINTF@
999 1.1 christos _GL_FUNCDECL_SYS (obstack_vprintf, int,
1000 1.1 christos (struct obstack *obs, const char *format, va_list args)
1001 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1002 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1003 1.1 christos # endif
1004 1.1 christos _GL_CXXALIAS_SYS (obstack_vprintf, int,
1005 1.1 christos (struct obstack *obs, const char *format, va_list args));
1006 1.1 christos # endif
1007 1.1 christos _GL_CXXALIASWARN (obstack_vprintf);
1008 1.1 christos #endif
1009 1.1 christos
1010 1.1 christos #if @GNULIB_PCLOSE@
1011 1.1 christos # if !@HAVE_PCLOSE@
1012 1.1 christos _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
1013 1.1 christos # endif
1014 1.1 christos _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
1015 1.1 christos _GL_CXXALIASWARN (pclose);
1016 1.1 christos #elif defined GNULIB_POSIXCHECK
1017 1.1 christos # undef pclose
1018 1.1 christos # if HAVE_RAW_DECL_PCLOSE
1019 1.1 christos _GL_WARN_ON_USE (pclose, "pclose is unportable - "
1020 1.1 christos "use gnulib module pclose for more portability");
1021 1.1 christos # endif
1022 1.1 christos #endif
1023 1.1 christos
1024 1.1 christos #if @GNULIB_PERROR@
1025 1.1 christos /* Print a message to standard error, describing the value of ERRNO,
1026 1.1 christos (if STRING is not NULL and not empty) prefixed with STRING and ": ",
1027 1.1 christos and terminated with a newline. */
1028 1.1 christos # if @REPLACE_PERROR@
1029 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1030 1.1 christos # define perror rpl_perror
1031 1.1 christos # endif
1032 1.1 christos _GL_FUNCDECL_RPL (perror, void, (const char *string));
1033 1.1 christos _GL_CXXALIAS_RPL (perror, void, (const char *string));
1034 1.1 christos # else
1035 1.1 christos _GL_CXXALIAS_SYS (perror, void, (const char *string));
1036 1.1 christos # endif
1037 1.1 christos # if __GLIBC__ >= 2
1038 1.1 christos _GL_CXXALIASWARN (perror);
1039 1.1 christos # endif
1040 1.1 christos #elif defined GNULIB_POSIXCHECK
1041 1.1 christos # undef perror
1042 1.1 christos /* Assume perror is always declared. */
1043 1.1 christos _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1044 1.1 christos "use gnulib module perror for portability");
1045 1.1 christos #endif
1046 1.1 christos
1047 1.1 christos #if @GNULIB_POPEN@
1048 1.1 christos # if @REPLACE_POPEN@
1049 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1050 1.1 christos # undef popen
1051 1.1 christos # define popen rpl_popen
1052 1.1 christos # endif
1053 1.1.1.2 christos _GL_FUNCDECL_RPL (popen, FILE *,
1054 1.1.1.2 christos (const char *cmd, const char *mode)
1055 1.1.1.2 christos _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
1056 1.1 christos _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
1057 1.1 christos # else
1058 1.1.1.2 christos # if !@HAVE_POPEN@ || __GNUC__ >= 11
1059 1.1.1.2 christos _GL_FUNCDECL_SYS (popen, FILE *,
1060 1.1.1.2 christos (const char *cmd, const char *mode)
1061 1.1.1.2 christos _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
1062 1.1 christos # endif
1063 1.1 christos _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
1064 1.1 christos # endif
1065 1.1 christos _GL_CXXALIASWARN (popen);
1066 1.1.1.2 christos #else
1067 1.1.1.2 christos # if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
1068 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1069 1.1.1.2 christos _GL_FUNCDECL_SYS (popen, FILE *,
1070 1.1.1.2 christos (const char *cmd, const char *mode)
1071 1.1.1.2 christos _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
1072 1.1.1.2 christos # endif
1073 1.1.1.2 christos # if defined GNULIB_POSIXCHECK
1074 1.1.1.2 christos # undef popen
1075 1.1.1.2 christos # if HAVE_RAW_DECL_POPEN
1076 1.1 christos _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1077 1.1 christos "use gnulib module popen or pipe for more portability");
1078 1.1.1.2 christos # endif
1079 1.1 christos # endif
1080 1.1 christos #endif
1081 1.1 christos
1082 1.1 christos #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
1083 1.1 christos # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
1084 1.1 christos || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1085 1.1.1.2 christos # if defined __GNUC__ || defined __clang__
1086 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1087 1.1 christos /* Don't break __attribute__((format(printf,M,N))). */
1088 1.1 christos # define printf __printf__
1089 1.1 christos # endif
1090 1.1 christos # if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1091 1.1 christos _GL_FUNCDECL_RPL_1 (__printf__, int,
1092 1.1 christos (const char *restrict format, ...)
1093 1.1 christos __asm__ (@ASM_SYMBOL_PREFIX@
1094 1.1 christos _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
1095 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1096 1.1 christos _GL_ARG_NONNULL ((1)));
1097 1.1 christos # else
1098 1.1 christos _GL_FUNCDECL_RPL_1 (__printf__, int,
1099 1.1 christos (const char *restrict format, ...)
1100 1.1 christos __asm__ (@ASM_SYMBOL_PREFIX@
1101 1.1 christos _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
1102 1.1 christos _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
1103 1.1 christos _GL_ARG_NONNULL ((1)));
1104 1.1 christos # endif
1105 1.1 christos _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
1106 1.1 christos # else
1107 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1108 1.1 christos # define printf rpl_printf
1109 1.1 christos # endif
1110 1.1 christos _GL_FUNCDECL_RPL (printf, int,
1111 1.1 christos (const char *restrict format, ...)
1112 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1113 1.1 christos _GL_ARG_NONNULL ((1)));
1114 1.1 christos _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
1115 1.1 christos # endif
1116 1.1 christos # define GNULIB_overrides_printf 1
1117 1.1 christos # else
1118 1.1 christos _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
1119 1.1 christos # endif
1120 1.1 christos # if __GLIBC__ >= 2
1121 1.1 christos _GL_CXXALIASWARN (printf);
1122 1.1 christos # endif
1123 1.1 christos #endif
1124 1.1 christos #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1125 1.1 christos # if !GNULIB_overrides_printf
1126 1.1 christos # undef printf
1127 1.1 christos # endif
1128 1.1 christos /* Assume printf is always declared. */
1129 1.1 christos _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1130 1.1 christos "use gnulib module printf-posix for portable "
1131 1.1 christos "POSIX compliance");
1132 1.1 christos #endif
1133 1.1 christos
1134 1.1 christos #if @GNULIB_PUTC@
1135 1.1 christos # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
1136 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1137 1.1 christos # undef putc
1138 1.1 christos # define putc rpl_fputc
1139 1.1 christos # endif
1140 1.1 christos _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
1141 1.1 christos _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
1142 1.1 christos # else
1143 1.1 christos _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
1144 1.1 christos # endif
1145 1.1 christos # if __GLIBC__ >= 2
1146 1.1 christos _GL_CXXALIASWARN (putc);
1147 1.1 christos # endif
1148 1.1 christos #endif
1149 1.1 christos
1150 1.1 christos #if @GNULIB_PUTCHAR@
1151 1.1 christos # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
1152 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1153 1.1 christos # undef putchar
1154 1.1 christos # define putchar rpl_putchar
1155 1.1 christos # endif
1156 1.1 christos _GL_FUNCDECL_RPL (putchar, int, (int c));
1157 1.1 christos _GL_CXXALIAS_RPL (putchar, int, (int c));
1158 1.1 christos # else
1159 1.1 christos _GL_CXXALIAS_SYS (putchar, int, (int c));
1160 1.1 christos # endif
1161 1.1 christos # if __GLIBC__ >= 2
1162 1.1 christos _GL_CXXALIASWARN (putchar);
1163 1.1 christos # endif
1164 1.1 christos #endif
1165 1.1 christos
1166 1.1 christos #if @GNULIB_PUTS@
1167 1.1 christos # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
1168 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1169 1.1 christos # undef puts
1170 1.1 christos # define puts rpl_puts
1171 1.1 christos # endif
1172 1.1 christos _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
1173 1.1 christos _GL_CXXALIAS_RPL (puts, int, (const char *string));
1174 1.1 christos # else
1175 1.1 christos _GL_CXXALIAS_SYS (puts, int, (const char *string));
1176 1.1 christos # endif
1177 1.1 christos # if __GLIBC__ >= 2
1178 1.1 christos _GL_CXXALIASWARN (puts);
1179 1.1 christos # endif
1180 1.1 christos #endif
1181 1.1 christos
1182 1.1.1.2 christos #if @GNULIB_MDA_PUTW@
1183 1.1.1.2 christos /* On native Windows, map 'putw' to '_putw', so that -loldnames is not
1184 1.1.1.2 christos required. In C++ with GNULIB_NAMESPACE, avoid differences between
1185 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::putw always. */
1186 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
1187 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1188 1.1.1.2 christos # undef putw
1189 1.1.1.2 christos # define putw _putw
1190 1.1.1.2 christos # endif
1191 1.1.1.2 christos _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1192 1.1.1.2 christos # else
1193 1.1.1.2 christos _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1194 1.1.1.2 christos # endif
1195 1.1.1.2 christos _GL_CXXALIASWARN (putw);
1196 1.1.1.2 christos #endif
1197 1.1.1.2 christos
1198 1.1 christos #if @GNULIB_REMOVE@
1199 1.1 christos # if @REPLACE_REMOVE@
1200 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1201 1.1 christos # undef remove
1202 1.1 christos # define remove rpl_remove
1203 1.1 christos # endif
1204 1.1 christos _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
1205 1.1 christos _GL_CXXALIAS_RPL (remove, int, (const char *name));
1206 1.1 christos # else
1207 1.1 christos _GL_CXXALIAS_SYS (remove, int, (const char *name));
1208 1.1 christos # endif
1209 1.1 christos # if __GLIBC__ >= 2
1210 1.1 christos _GL_CXXALIASWARN (remove);
1211 1.1 christos # endif
1212 1.1 christos #elif defined GNULIB_POSIXCHECK
1213 1.1 christos # undef remove
1214 1.1 christos /* Assume remove is always declared. */
1215 1.1 christos _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
1216 1.1 christos "use gnulib module remove for more portability");
1217 1.1 christos #endif
1218 1.1 christos
1219 1.1 christos #if @GNULIB_RENAME@
1220 1.1 christos # if @REPLACE_RENAME@
1221 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1222 1.1 christos # undef rename
1223 1.1 christos # define rename rpl_rename
1224 1.1 christos # endif
1225 1.1 christos _GL_FUNCDECL_RPL (rename, int,
1226 1.1 christos (const char *old_filename, const char *new_filename)
1227 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1228 1.1 christos _GL_CXXALIAS_RPL (rename, int,
1229 1.1 christos (const char *old_filename, const char *new_filename));
1230 1.1 christos # else
1231 1.1 christos _GL_CXXALIAS_SYS (rename, int,
1232 1.1 christos (const char *old_filename, const char *new_filename));
1233 1.1 christos # endif
1234 1.1 christos # if __GLIBC__ >= 2
1235 1.1 christos _GL_CXXALIASWARN (rename);
1236 1.1 christos # endif
1237 1.1 christos #elif defined GNULIB_POSIXCHECK
1238 1.1 christos # undef rename
1239 1.1 christos /* Assume rename is always declared. */
1240 1.1 christos _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
1241 1.1 christos "use gnulib module rename for more portability");
1242 1.1 christos #endif
1243 1.1 christos
1244 1.1 christos #if @GNULIB_RENAMEAT@
1245 1.1 christos # if @REPLACE_RENAMEAT@
1246 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1247 1.1 christos # undef renameat
1248 1.1 christos # define renameat rpl_renameat
1249 1.1 christos # endif
1250 1.1 christos _GL_FUNCDECL_RPL (renameat, int,
1251 1.1 christos (int fd1, char const *file1, int fd2, char const *file2)
1252 1.1 christos _GL_ARG_NONNULL ((2, 4)));
1253 1.1 christos _GL_CXXALIAS_RPL (renameat, int,
1254 1.1 christos (int fd1, char const *file1, int fd2, char const *file2));
1255 1.1 christos # else
1256 1.1 christos # if !@HAVE_RENAMEAT@
1257 1.1 christos _GL_FUNCDECL_SYS (renameat, int,
1258 1.1 christos (int fd1, char const *file1, int fd2, char const *file2)
1259 1.1 christos _GL_ARG_NONNULL ((2, 4)));
1260 1.1 christos # endif
1261 1.1 christos _GL_CXXALIAS_SYS (renameat, int,
1262 1.1 christos (int fd1, char const *file1, int fd2, char const *file2));
1263 1.1 christos # endif
1264 1.1 christos _GL_CXXALIASWARN (renameat);
1265 1.1 christos #elif defined GNULIB_POSIXCHECK
1266 1.1 christos # undef renameat
1267 1.1 christos # if HAVE_RAW_DECL_RENAMEAT
1268 1.1 christos _GL_WARN_ON_USE (renameat, "renameat is not portable - "
1269 1.1 christos "use gnulib module renameat for portability");
1270 1.1 christos # endif
1271 1.1 christos #endif
1272 1.1 christos
1273 1.1 christos #if @GNULIB_SCANF@
1274 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1275 1.1.1.2 christos # if defined __GNUC__ || defined __clang__
1276 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1277 1.1 christos # undef scanf
1278 1.1 christos /* Don't break __attribute__((format(scanf,M,N))). */
1279 1.1 christos # define scanf __scanf__
1280 1.1 christos # endif
1281 1.1 christos _GL_FUNCDECL_RPL_1 (__scanf__, int,
1282 1.1 christos (const char *restrict format, ...)
1283 1.1 christos __asm__ (@ASM_SYMBOL_PREFIX@
1284 1.1 christos _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
1285 1.1 christos _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1286 1.1 christos _GL_ARG_NONNULL ((1)));
1287 1.1 christos _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
1288 1.1 christos # else
1289 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1290 1.1 christos # undef scanf
1291 1.1 christos # define scanf rpl_scanf
1292 1.1 christos # endif
1293 1.1 christos _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
1294 1.1 christos _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1295 1.1 christos _GL_ARG_NONNULL ((1)));
1296 1.1 christos _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
1297 1.1 christos # endif
1298 1.1 christos # else
1299 1.1 christos _GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
1300 1.1 christos # endif
1301 1.1 christos # if __GLIBC__ >= 2
1302 1.1 christos _GL_CXXALIASWARN (scanf);
1303 1.1 christos # endif
1304 1.1 christos #endif
1305 1.1 christos
1306 1.1 christos #if @GNULIB_SNPRINTF@
1307 1.1 christos # if @REPLACE_SNPRINTF@
1308 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1309 1.1 christos # define snprintf rpl_snprintf
1310 1.1 christos # endif
1311 1.1.1.2 christos # define GNULIB_overrides_snprintf 1
1312 1.1 christos _GL_FUNCDECL_RPL (snprintf, int,
1313 1.1 christos (char *restrict str, size_t size,
1314 1.1 christos const char *restrict format, ...)
1315 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1316 1.1 christos _GL_ARG_NONNULL ((3)));
1317 1.1 christos _GL_CXXALIAS_RPL (snprintf, int,
1318 1.1 christos (char *restrict str, size_t size,
1319 1.1 christos const char *restrict format, ...));
1320 1.1 christos # else
1321 1.1 christos # if !@HAVE_DECL_SNPRINTF@
1322 1.1 christos _GL_FUNCDECL_SYS (snprintf, int,
1323 1.1 christos (char *restrict str, size_t size,
1324 1.1 christos const char *restrict format, ...)
1325 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1326 1.1 christos _GL_ARG_NONNULL ((3)));
1327 1.1 christos # endif
1328 1.1 christos _GL_CXXALIAS_SYS (snprintf, int,
1329 1.1 christos (char *restrict str, size_t size,
1330 1.1 christos const char *restrict format, ...));
1331 1.1 christos # endif
1332 1.1.1.2 christos # if __GLIBC__ >= 2
1333 1.1 christos _GL_CXXALIASWARN (snprintf);
1334 1.1.1.2 christos # endif
1335 1.1 christos #elif defined GNULIB_POSIXCHECK
1336 1.1 christos # undef snprintf
1337 1.1 christos # if HAVE_RAW_DECL_SNPRINTF
1338 1.1 christos _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1339 1.1 christos "use gnulib module snprintf for portability");
1340 1.1 christos # endif
1341 1.1 christos #endif
1342 1.1 christos
1343 1.1 christos /* Some people would argue that all sprintf uses should be warned about
1344 1.1 christos (for example, OpenBSD issues a link warning for it),
1345 1.1 christos since it can cause security holes due to buffer overruns.
1346 1.1 christos However, we believe that sprintf can be used safely, and is more
1347 1.1 christos efficient than snprintf in those safe cases; and as proof of our
1348 1.1 christos belief, we use sprintf in several gnulib modules. So this header
1349 1.1 christos intentionally avoids adding a warning to sprintf except when
1350 1.1 christos GNULIB_POSIXCHECK is defined. */
1351 1.1 christos
1352 1.1 christos #if @GNULIB_SPRINTF_POSIX@
1353 1.1 christos # if @REPLACE_SPRINTF@
1354 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1355 1.1 christos # define sprintf rpl_sprintf
1356 1.1 christos # endif
1357 1.1.1.2 christos # define GNULIB_overrides_sprintf 1
1358 1.1 christos _GL_FUNCDECL_RPL (sprintf, int,
1359 1.1 christos (char *restrict str, const char *restrict format, ...)
1360 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1361 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1362 1.1 christos _GL_CXXALIAS_RPL (sprintf, int,
1363 1.1 christos (char *restrict str, const char *restrict format, ...));
1364 1.1 christos # else
1365 1.1 christos _GL_CXXALIAS_SYS (sprintf, int,
1366 1.1 christos (char *restrict str, const char *restrict format, ...));
1367 1.1 christos # endif
1368 1.1 christos # if __GLIBC__ >= 2
1369 1.1 christos _GL_CXXALIASWARN (sprintf);
1370 1.1 christos # endif
1371 1.1 christos #elif defined GNULIB_POSIXCHECK
1372 1.1 christos # undef sprintf
1373 1.1 christos /* Assume sprintf is always declared. */
1374 1.1 christos _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1375 1.1 christos "use gnulib module sprintf-posix for portable "
1376 1.1 christos "POSIX compliance");
1377 1.1 christos #endif
1378 1.1 christos
1379 1.1.1.2 christos #if @GNULIB_MDA_TEMPNAM@
1380 1.1.1.2 christos /* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
1381 1.1.1.2 christos required. In C++ with GNULIB_NAMESPACE, avoid differences between
1382 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::tempnam always. */
1383 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
1384 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1385 1.1.1.2 christos # undef tempnam
1386 1.1.1.2 christos # define tempnam _tempnam
1387 1.1.1.2 christos # endif
1388 1.1.1.2 christos _GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix));
1389 1.1.1.2 christos # else
1390 1.1.1.2 christos _GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix));
1391 1.1.1.2 christos # endif
1392 1.1.1.2 christos _GL_CXXALIASWARN (tempnam);
1393 1.1.1.2 christos #endif
1394 1.1.1.2 christos
1395 1.1 christos #if @GNULIB_TMPFILE@
1396 1.1 christos # if @REPLACE_TMPFILE@
1397 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1398 1.1 christos # define tmpfile rpl_tmpfile
1399 1.1 christos # endif
1400 1.1.1.2 christos _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
1401 1.1.1.2 christos _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1402 1.1 christos _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1403 1.1 christos # else
1404 1.1.1.2 christos # if __GNUC__ >= 11
1405 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1406 1.1.1.2 christos _GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1407 1.1.1.2 christos _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1408 1.1.1.2 christos # endif
1409 1.1 christos _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1410 1.1 christos # endif
1411 1.1 christos # if __GLIBC__ >= 2
1412 1.1 christos _GL_CXXALIASWARN (tmpfile);
1413 1.1 christos # endif
1414 1.1.1.2 christos #else
1415 1.1.1.2 christos # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
1416 1.1.1.2 christos /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1417 1.1.1.2 christos _GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1418 1.1.1.2 christos _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1419 1.1.1.2 christos # endif
1420 1.1.1.2 christos # if defined GNULIB_POSIXCHECK
1421 1.1.1.2 christos # undef tmpfile
1422 1.1.1.2 christos # if HAVE_RAW_DECL_TMPFILE
1423 1.1 christos _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1424 1.1 christos "use gnulib module tmpfile for portability");
1425 1.1.1.2 christos # endif
1426 1.1 christos # endif
1427 1.1 christos #endif
1428 1.1 christos
1429 1.1 christos #if @GNULIB_VASPRINTF@
1430 1.1 christos /* Write formatted output to a string dynamically allocated with malloc().
1431 1.1 christos If the memory allocation succeeds, store the address of the string in
1432 1.1 christos *RESULT and return the number of resulting bytes, excluding the trailing
1433 1.1 christos NUL. Upon memory allocation error, or some other error, return -1. */
1434 1.1 christos # if @REPLACE_VASPRINTF@
1435 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1436 1.1 christos # define asprintf rpl_asprintf
1437 1.1 christos # endif
1438 1.1.1.2 christos # define GNULIB_overrides_asprintf
1439 1.1 christos _GL_FUNCDECL_RPL (asprintf, int,
1440 1.1 christos (char **result, const char *format, ...)
1441 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1442 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1443 1.1 christos _GL_CXXALIAS_RPL (asprintf, int,
1444 1.1 christos (char **result, const char *format, ...));
1445 1.1 christos # else
1446 1.1 christos # if !@HAVE_VASPRINTF@
1447 1.1 christos _GL_FUNCDECL_SYS (asprintf, int,
1448 1.1 christos (char **result, const char *format, ...)
1449 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1450 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1451 1.1 christos # endif
1452 1.1 christos _GL_CXXALIAS_SYS (asprintf, int,
1453 1.1 christos (char **result, const char *format, ...));
1454 1.1 christos # endif
1455 1.1 christos _GL_CXXALIASWARN (asprintf);
1456 1.1 christos # if @REPLACE_VASPRINTF@
1457 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1458 1.1 christos # define vasprintf rpl_vasprintf
1459 1.1 christos # endif
1460 1.1.1.2 christos # define GNULIB_overrides_vasprintf 1
1461 1.1 christos _GL_FUNCDECL_RPL (vasprintf, int,
1462 1.1 christos (char **result, const char *format, va_list args)
1463 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1464 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1465 1.1 christos _GL_CXXALIAS_RPL (vasprintf, int,
1466 1.1 christos (char **result, const char *format, va_list args));
1467 1.1 christos # else
1468 1.1 christos # if !@HAVE_VASPRINTF@
1469 1.1 christos _GL_FUNCDECL_SYS (vasprintf, int,
1470 1.1 christos (char **result, const char *format, va_list args)
1471 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1472 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1473 1.1 christos # endif
1474 1.1 christos _GL_CXXALIAS_SYS (vasprintf, int,
1475 1.1 christos (char **result, const char *format, va_list args));
1476 1.1 christos # endif
1477 1.1 christos _GL_CXXALIASWARN (vasprintf);
1478 1.1 christos #endif
1479 1.1 christos
1480 1.1 christos #if @GNULIB_VDPRINTF@
1481 1.1 christos # if @REPLACE_VDPRINTF@
1482 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1483 1.1 christos # define vdprintf rpl_vdprintf
1484 1.1 christos # endif
1485 1.1 christos _GL_FUNCDECL_RPL (vdprintf, int,
1486 1.1 christos (int fd, const char *restrict format, va_list args)
1487 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1488 1.1 christos _GL_ARG_NONNULL ((2)));
1489 1.1 christos _GL_CXXALIAS_RPL (vdprintf, int,
1490 1.1 christos (int fd, const char *restrict format, va_list args));
1491 1.1 christos # else
1492 1.1 christos # if !@HAVE_VDPRINTF@
1493 1.1 christos _GL_FUNCDECL_SYS (vdprintf, int,
1494 1.1 christos (int fd, const char *restrict format, va_list args)
1495 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1496 1.1 christos _GL_ARG_NONNULL ((2)));
1497 1.1 christos # endif
1498 1.1 christos /* Need to cast, because on Solaris, the third parameter will likely be
1499 1.1 christos __va_list args. */
1500 1.1 christos _GL_CXXALIAS_SYS_CAST (vdprintf, int,
1501 1.1 christos (int fd, const char *restrict format, va_list args));
1502 1.1 christos # endif
1503 1.1 christos # if __GLIBC__ >= 2
1504 1.1 christos _GL_CXXALIASWARN (vdprintf);
1505 1.1 christos # endif
1506 1.1 christos #elif defined GNULIB_POSIXCHECK
1507 1.1 christos # undef vdprintf
1508 1.1 christos # if HAVE_RAW_DECL_VDPRINTF
1509 1.1 christos _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1510 1.1 christos "use gnulib module vdprintf for portability");
1511 1.1 christos # endif
1512 1.1 christos #endif
1513 1.1 christos
1514 1.1 christos #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
1515 1.1 christos # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
1516 1.1 christos || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1517 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1518 1.1 christos # define vfprintf rpl_vfprintf
1519 1.1 christos # endif
1520 1.1 christos # define GNULIB_overrides_vfprintf 1
1521 1.1 christos # if @GNULIB_VFPRINTF_POSIX@
1522 1.1 christos _GL_FUNCDECL_RPL (vfprintf, int,
1523 1.1 christos (FILE *restrict fp,
1524 1.1 christos const char *restrict format, va_list args)
1525 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1526 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1527 1.1 christos # else
1528 1.1 christos _GL_FUNCDECL_RPL (vfprintf, int,
1529 1.1 christos (FILE *restrict fp,
1530 1.1 christos const char *restrict format, va_list args)
1531 1.1 christos _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1532 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1533 1.1 christos # endif
1534 1.1 christos _GL_CXXALIAS_RPL (vfprintf, int,
1535 1.1 christos (FILE *restrict fp,
1536 1.1 christos const char *restrict format, va_list args));
1537 1.1 christos # else
1538 1.1 christos /* Need to cast, because on Solaris, the third parameter is
1539 1.1 christos __va_list args
1540 1.1 christos and GCC's fixincludes did not change this to __gnuc_va_list. */
1541 1.1 christos _GL_CXXALIAS_SYS_CAST (vfprintf, int,
1542 1.1 christos (FILE *restrict fp,
1543 1.1 christos const char *restrict format, va_list args));
1544 1.1 christos # endif
1545 1.1 christos # if __GLIBC__ >= 2
1546 1.1 christos _GL_CXXALIASWARN (vfprintf);
1547 1.1 christos # endif
1548 1.1 christos #endif
1549 1.1 christos #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1550 1.1 christos # if !GNULIB_overrides_vfprintf
1551 1.1 christos # undef vfprintf
1552 1.1 christos # endif
1553 1.1 christos /* Assume vfprintf is always declared. */
1554 1.1 christos _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1555 1.1 christos "use gnulib module vfprintf-posix for portable "
1556 1.1 christos "POSIX compliance");
1557 1.1 christos #endif
1558 1.1 christos
1559 1.1 christos #if @GNULIB_VFSCANF@
1560 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1561 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1562 1.1 christos # undef vfscanf
1563 1.1 christos # define vfscanf rpl_vfscanf
1564 1.1 christos # endif
1565 1.1 christos _GL_FUNCDECL_RPL (vfscanf, int,
1566 1.1 christos (FILE *restrict stream,
1567 1.1 christos const char *restrict format, va_list args)
1568 1.1 christos _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1569 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1570 1.1 christos _GL_CXXALIAS_RPL (vfscanf, int,
1571 1.1 christos (FILE *restrict stream,
1572 1.1 christos const char *restrict format, va_list args));
1573 1.1 christos # else
1574 1.1 christos _GL_CXXALIAS_SYS (vfscanf, int,
1575 1.1 christos (FILE *restrict stream,
1576 1.1 christos const char *restrict format, va_list args));
1577 1.1 christos # endif
1578 1.1.1.2 christos # if __GLIBC__ >= 2
1579 1.1 christos _GL_CXXALIASWARN (vfscanf);
1580 1.1.1.2 christos # endif
1581 1.1 christos #endif
1582 1.1 christos
1583 1.1 christos #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
1584 1.1 christos # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
1585 1.1 christos || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1586 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1587 1.1 christos # define vprintf rpl_vprintf
1588 1.1 christos # endif
1589 1.1 christos # define GNULIB_overrides_vprintf 1
1590 1.1 christos # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1591 1.1 christos _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1592 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1593 1.1 christos _GL_ARG_NONNULL ((1)));
1594 1.1 christos # else
1595 1.1 christos _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1596 1.1 christos _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1597 1.1 christos _GL_ARG_NONNULL ((1)));
1598 1.1 christos # endif
1599 1.1 christos _GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
1600 1.1 christos # else
1601 1.1 christos /* Need to cast, because on Solaris, the second parameter is
1602 1.1 christos __va_list args
1603 1.1 christos and GCC's fixincludes did not change this to __gnuc_va_list. */
1604 1.1 christos _GL_CXXALIAS_SYS_CAST (vprintf, int,
1605 1.1 christos (const char *restrict format, va_list args));
1606 1.1 christos # endif
1607 1.1 christos # if __GLIBC__ >= 2
1608 1.1 christos _GL_CXXALIASWARN (vprintf);
1609 1.1 christos # endif
1610 1.1 christos #endif
1611 1.1 christos #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1612 1.1 christos # if !GNULIB_overrides_vprintf
1613 1.1 christos # undef vprintf
1614 1.1 christos # endif
1615 1.1 christos /* Assume vprintf is always declared. */
1616 1.1 christos _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1617 1.1 christos "use gnulib module vprintf-posix for portable "
1618 1.1 christos "POSIX compliance");
1619 1.1 christos #endif
1620 1.1 christos
1621 1.1 christos #if @GNULIB_VSCANF@
1622 1.1 christos # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1623 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1624 1.1 christos # undef vscanf
1625 1.1 christos # define vscanf rpl_vscanf
1626 1.1 christos # endif
1627 1.1 christos _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
1628 1.1 christos _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1629 1.1 christos _GL_ARG_NONNULL ((1)));
1630 1.1 christos _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1631 1.1 christos # else
1632 1.1 christos _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
1633 1.1 christos # endif
1634 1.1.1.2 christos # if __GLIBC__ >= 2
1635 1.1 christos _GL_CXXALIASWARN (vscanf);
1636 1.1.1.2 christos # endif
1637 1.1 christos #endif
1638 1.1 christos
1639 1.1 christos #if @GNULIB_VSNPRINTF@
1640 1.1 christos # if @REPLACE_VSNPRINTF@
1641 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1642 1.1 christos # define vsnprintf rpl_vsnprintf
1643 1.1 christos # endif
1644 1.1.1.2 christos # define GNULIB_overrides_vsnprintf 1
1645 1.1 christos _GL_FUNCDECL_RPL (vsnprintf, int,
1646 1.1 christos (char *restrict str, size_t size,
1647 1.1 christos const char *restrict format, va_list args)
1648 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1649 1.1 christos _GL_ARG_NONNULL ((3)));
1650 1.1 christos _GL_CXXALIAS_RPL (vsnprintf, int,
1651 1.1 christos (char *restrict str, size_t size,
1652 1.1 christos const char *restrict format, va_list args));
1653 1.1 christos # else
1654 1.1 christos # if !@HAVE_DECL_VSNPRINTF@
1655 1.1 christos _GL_FUNCDECL_SYS (vsnprintf, int,
1656 1.1 christos (char *restrict str, size_t size,
1657 1.1 christos const char *restrict format, va_list args)
1658 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1659 1.1 christos _GL_ARG_NONNULL ((3)));
1660 1.1 christos # endif
1661 1.1 christos _GL_CXXALIAS_SYS (vsnprintf, int,
1662 1.1 christos (char *restrict str, size_t size,
1663 1.1 christos const char *restrict format, va_list args));
1664 1.1 christos # endif
1665 1.1.1.2 christos # if __GLIBC__ >= 2
1666 1.1 christos _GL_CXXALIASWARN (vsnprintf);
1667 1.1.1.2 christos # endif
1668 1.1 christos #elif defined GNULIB_POSIXCHECK
1669 1.1 christos # undef vsnprintf
1670 1.1 christos # if HAVE_RAW_DECL_VSNPRINTF
1671 1.1 christos _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1672 1.1 christos "use gnulib module vsnprintf for portability");
1673 1.1 christos # endif
1674 1.1 christos #endif
1675 1.1 christos
1676 1.1 christos #if @GNULIB_VSPRINTF_POSIX@
1677 1.1 christos # if @REPLACE_VSPRINTF@
1678 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1679 1.1 christos # define vsprintf rpl_vsprintf
1680 1.1 christos # endif
1681 1.1.1.2 christos # define GNULIB_overrides_vsprintf 1
1682 1.1 christos _GL_FUNCDECL_RPL (vsprintf, int,
1683 1.1 christos (char *restrict str,
1684 1.1 christos const char *restrict format, va_list args)
1685 1.1.1.2 christos _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1686 1.1 christos _GL_ARG_NONNULL ((1, 2)));
1687 1.1 christos _GL_CXXALIAS_RPL (vsprintf, int,
1688 1.1 christos (char *restrict str,
1689 1.1 christos const char *restrict format, va_list args));
1690 1.1 christos # else
1691 1.1 christos /* Need to cast, because on Solaris, the third parameter is
1692 1.1 christos __va_list args
1693 1.1 christos and GCC's fixincludes did not change this to __gnuc_va_list. */
1694 1.1 christos _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1695 1.1 christos (char *restrict str,
1696 1.1 christos const char *restrict format, va_list args));
1697 1.1 christos # endif
1698 1.1 christos # if __GLIBC__ >= 2
1699 1.1 christos _GL_CXXALIASWARN (vsprintf);
1700 1.1 christos # endif
1701 1.1 christos #elif defined GNULIB_POSIXCHECK
1702 1.1 christos # undef vsprintf
1703 1.1 christos /* Assume vsprintf is always declared. */
1704 1.1 christos _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1705 1.1 christos "use gnulib module vsprintf-posix for portable "
1706 1.1 christos "POSIX compliance");
1707 1.1 christos #endif
1708 1.1 christos
1709 1.1 christos #endif /* _@GUARD_PREFIX@_STDIO_H */
1710 1.1 christos #endif /* _@GUARD_PREFIX@_STDIO_H */
1711 1.1 christos #endif
1712