Debian Codegraph @

lib/stdio.in.h

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