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