Debian Codegraph @

tools/gnulib/stdio.in.h

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