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