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