Line data Source code
1 : /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 : /* A GNU-like <stdio.h>.
3 :
4 : Copyright (C) 2004, 2007-2025 Free Software Foundation, Inc.
5 :
6 : This file is free software: you can redistribute it and/or modify
7 : it under the terms of the GNU Lesser General Public License as
8 : published by the Free Software Foundation; either version 2.1 of the
9 : License, or (at your option) any later version.
10 :
11 : This file is distributed in the hope that it will be useful,
12 : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : GNU Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public License
17 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 :
19 : #if __GNUC__ >= 3
20 : #pragma GCC system_header
21 : #endif
22 :
23 :
24 : #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H || defined _GL_SKIP_GNULIB_STDIO_H
25 : /* Special invocation convention:
26 : - Inside glibc header files.
27 : - On OSF/1 5.1 we have a sequence of nested includes
28 : <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
29 : <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
30 : In this situation, the functions are not yet declared, therefore we cannot
31 : provide the C++ aliases. */
32 :
33 : #include_next <stdio.h>
34 :
35 : #else
36 : /* Normal invocation convention. */
37 :
38 : #ifndef _GL_STDIO_H
39 :
40 : /* Suppress macOS deprecation warnings for sprintf and vsprintf. */
41 : #if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
42 : # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
43 : # include <AvailabilityMacros.h>
44 : # endif
45 : # if (defined MAC_OS_X_VERSION_MIN_REQUIRED \
46 : && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED)
47 : # define _POSIX_C_SOURCE 200809L
48 : # define _GL_DEFINED__POSIX_C_SOURCE
49 : # endif
50 : #endif
51 :
52 : #define _GL_ALREADY_INCLUDING_STDIO_H
53 :
54 : /* The include_next requires a split double-inclusion guard. */
55 : #include_next <stdio.h>
56 :
57 : #undef _GL_ALREADY_INCLUDING_STDIO_H
58 :
59 : #ifdef _GL_DEFINED__POSIX_C_SOURCE
60 : # undef _GL_DEFINED__POSIX_C_SOURCE
61 : # undef _POSIX_C_SOURCE
62 : #endif
63 :
64 : #ifndef _GL_STDIO_H
65 : #define _GL_STDIO_H
66 :
67 : /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
68 : _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW,
69 : GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
70 : #if !_GL_CONFIG_H_INCLUDED
71 : #error "Please include config.h first."
72 : #endif
73 :
74 : /* Get va_list. Needed on many systems, including glibc 2.8. */
75 : #include <stdarg.h>
76 :
77 : #include <stddef.h>
78 :
79 : /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
80 : and eglibc 2.11.2.
81 : May also define off_t to a 64-bit type on native Windows.
82 : Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
83 : #include <sys/types.h>
84 :
85 : /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
86 : /* But in any case avoid namespace pollution on glibc systems. */
87 : #if (0 || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
88 : && ! defined __GLIBC__
89 : # include <unistd.h>
90 : #endif
91 :
92 : /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
93 : /* But in any case avoid namespace pollution on glibc systems. */
94 : #if (0 || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
95 : && ! defined __GLIBC__
96 : # include <sys/stat.h>
97 : #endif
98 :
99 : /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
100 : it before we #define perror rpl_perror. */
101 : /* But in any case avoid namespace pollution on glibc systems. */
102 : #if (0 || defined GNULIB_POSIXCHECK) \
103 : && (defined _WIN32 && ! defined __CYGWIN__) \
104 : && ! defined __GLIBC__
105 : # include <stdlib.h>
106 : #endif
107 :
108 : /* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
109 : it before we #define remove rpl_remove. */
110 : /* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
111 : it before we #define rename rpl_rename. */
112 : /* But in any case avoid namespace pollution on glibc systems. */
113 : #if (0 || 0 || defined GNULIB_POSIXCHECK) \
114 : && (defined _WIN32 && ! defined __CYGWIN__) \
115 : && ! defined __GLIBC__
116 : # include <io.h>
117 : #endif
118 :
119 :
120 : /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
121 : that can be freed by passing them as the Ith argument to the
122 : function F. */
123 : #ifndef _GL_ATTRIBUTE_DEALLOC
124 : # if __GNUC__ >= 11 && !defined __clang__
125 : # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
126 : # else
127 : # define _GL_ATTRIBUTE_DEALLOC(f, i)
128 : # endif
129 : #endif
130 :
131 : /* The __attribute__ feature is available in gcc versions 2.5 and later.
132 : The __-protected variants of the attributes 'format' and 'printf' are
133 : accepted by gcc versions 2.6.4 (effectively 2.7) and later.
134 : We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
135 : gnulib and libintl do '#define printf __printf__' when they override
136 : the 'printf' function. */
137 : #ifndef _GL_ATTRIBUTE_FORMAT
138 : # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
139 : # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
140 : # else
141 : # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
142 : # endif
143 : #endif
144 :
145 : /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
146 : allocated memory. */
147 : #ifndef _GL_ATTRIBUTE_MALLOC
148 : # if __GNUC__ >= 3 || defined __clang__
149 : # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
150 : # else
151 : # define _GL_ATTRIBUTE_MALLOC
152 : # endif
153 : #endif
154 :
155 : /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
156 : */
157 : #ifndef _GL_ATTRIBUTE_NOTHROW
158 : # if defined __cplusplus
159 : # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
160 : # if __cplusplus >= 201103L
161 : # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
162 : # else
163 : # define _GL_ATTRIBUTE_NOTHROW throw ()
164 : # endif
165 : # else
166 : # define _GL_ATTRIBUTE_NOTHROW
167 : # endif
168 : # else
169 : # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
170 : # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
171 : # else
172 : # define _GL_ATTRIBUTE_NOTHROW
173 : # endif
174 : # endif
175 : #endif
176 :
177 : /* An __attribute__ __format__ specifier for a function that takes a format
178 : string and arguments, where the format string directives are the ones
179 : standardized by ISO C99 and POSIX.
180 : _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
181 : /* __gnu_printf__ is supported in GCC >= 4.4. */
182 : #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
183 : # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
184 : #else
185 : # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
186 : #endif
187 :
188 : /* An __attribute__ __format__ specifier for a function that takes a format
189 : string and arguments, where the format string directives are the ones of the
190 : system printf(), rather than the ones standardized by ISO C99 and POSIX.
191 : _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */
192 : /* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
193 : the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
194 : whether this change is effective. On older mingw, it is not. */
195 : #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
196 : # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
197 : #else
198 : # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
199 : #endif
200 :
201 : /* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
202 : indicates to GCC that the function takes a format string and arguments,
203 : where the format string directives are the ones standardized by ISO C99
204 : and POSIX. */
205 : #define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
206 : _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
207 :
208 : /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
209 : except that it indicates to GCC that the supported format string directives
210 : are the ones of the system printf(), rather than the ones standardized by
211 : ISO C99 and POSIX. */
212 : #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
213 : _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
214 :
215 : /* _GL_ATTRIBUTE_FORMAT_SCANF
216 : indicates to GCC that the function takes a format string and arguments,
217 : where the format string directives are the ones standardized by ISO C99
218 : and POSIX. */
219 : #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
220 : # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
221 : _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
222 : #else
223 : # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
224 : _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
225 : #endif
226 :
227 : /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
228 : except that it indicates to GCC that the supported format string directives
229 : are the ones of the system scanf(), rather than the ones standardized by
230 : ISO C99 and POSIX. */
231 : #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
232 : _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
233 :
234 : /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
235 : /* C++ compatible function declaration macros.
236 : Copyright (C) 2010-2025 Free Software Foundation, Inc.
237 :
238 : This program is free software: you can redistribute it and/or modify it
239 : under the terms of the GNU Lesser General Public License as published
240 : by the Free Software Foundation; either version 2 of the License, or
241 : (at your option) any later version.
242 :
243 : This program is distributed in the hope that it will be useful,
244 : but WITHOUT ANY WARRANTY; without even the implied warranty of
245 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
246 : Lesser General Public License for more details.
247 :
248 : You should have received a copy of the GNU Lesser General Public License
249 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
250 :
251 : #ifndef _GL_CXXDEFS_H
252 : #define _GL_CXXDEFS_H
253 :
254 : /* Begin/end the GNULIB_NAMESPACE namespace. */
255 : #if defined __cplusplus && defined GNULIB_NAMESPACE
256 : # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
257 : # define _GL_END_NAMESPACE }
258 : #else
259 : # define _GL_BEGIN_NAMESPACE
260 : # define _GL_END_NAMESPACE
261 : #endif
262 :
263 : /* The three most frequent use cases of these macros are:
264 :
265 : * For providing a substitute for a function that is missing on some
266 : platforms, but is declared and works fine on the platforms on which
267 : it exists:
268 :
269 : #if @GNULIB_FOO@
270 : # if !@HAVE_FOO@
271 : _GL_FUNCDECL_SYS (foo, ...);
272 : # endif
273 : _GL_CXXALIAS_SYS (foo, ...);
274 : _GL_CXXALIASWARN (foo);
275 : #elif defined GNULIB_POSIXCHECK
276 : ...
277 : #endif
278 :
279 : * For providing a replacement for a function that exists on all platforms,
280 : but is broken/insufficient and needs to be replaced on some platforms:
281 :
282 : #if @GNULIB_FOO@
283 : # if @REPLACE_FOO@
284 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
285 : # undef foo
286 : # define foo rpl_foo
287 : # endif
288 : _GL_FUNCDECL_RPL (foo, ...);
289 : _GL_CXXALIAS_RPL (foo, ...);
290 : # else
291 : _GL_CXXALIAS_SYS (foo, ...);
292 : # endif
293 : _GL_CXXALIASWARN (foo);
294 : #elif defined GNULIB_POSIXCHECK
295 : ...
296 : #endif
297 :
298 : * For providing a replacement for a function that exists on some platforms
299 : but is broken/insufficient and needs to be replaced on some of them and
300 : is additionally either missing or undeclared on some other platforms:
301 :
302 : #if @GNULIB_FOO@
303 : # if @REPLACE_FOO@
304 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
305 : # undef foo
306 : # define foo rpl_foo
307 : # endif
308 : _GL_FUNCDECL_RPL (foo, ...);
309 : _GL_CXXALIAS_RPL (foo, ...);
310 : # else
311 : # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
312 : _GL_FUNCDECL_SYS (foo, ...);
313 : # endif
314 : _GL_CXXALIAS_SYS (foo, ...);
315 : # endif
316 : _GL_CXXALIASWARN (foo);
317 : #elif defined GNULIB_POSIXCHECK
318 : ...
319 : #endif
320 : */
321 :
322 : /* _GL_EXTERN_C declaration;
323 : performs the declaration with C linkage. */
324 : #if defined __cplusplus
325 : # define _GL_EXTERN_C extern "C"
326 : #else
327 : # define _GL_EXTERN_C extern
328 : #endif
329 :
330 : /* _GL_EXTERN_C_FUNC declaration;
331 : performs the declaration of a function with C linkage. */
332 : #if defined __cplusplus
333 : # define _GL_EXTERN_C_FUNC extern "C"
334 : #else
335 : /* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
336 : are not allowed between 'extern' and the return type (see gnulib-common.m4).
337 : */
338 : # define _GL_EXTERN_C_FUNC
339 : #endif
340 :
341 : /* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
342 : declares a replacement function, named rpl_func, with the given prototype,
343 : consisting of return type, parameters, and attributes.
344 : Although attributes are optional, the comma before them is required
345 : for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
346 : if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
347 : at the end of the declaration.
348 : Examples:
349 : _GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
350 : _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
351 : _GL_ARG_NONNULL ((1)));
352 :
353 : Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
354 : of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
355 : because
356 : [[...]] extern "C" <declaration>;
357 : is invalid syntax in C++.)
358 : */
359 : #define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
360 : _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
361 : #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
362 : _GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
363 :
364 : /* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
365 : declares the system function, named func, with the given prototype,
366 : consisting of return type, parameters, and attributes.
367 : Although attributes are optional, the comma before them is required
368 : for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
369 : if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
370 : at the end of the declaration.
371 : Examples:
372 : _GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
373 : _GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
374 : */
375 : #define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
376 : _GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters
377 :
378 : /* _GL_CXXALIAS_RPL (func, rettype, parameters);
379 : declares a C++ alias called GNULIB_NAMESPACE::func
380 : that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
381 : Example:
382 : _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
383 :
384 : Wrapping rpl_func in an object with an inline conversion operator
385 : avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
386 : actually used in the program. */
387 : #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
388 : _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
389 : #if defined __cplusplus && defined GNULIB_NAMESPACE
390 : # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
391 : namespace GNULIB_NAMESPACE \
392 : { \
393 : static const struct _gl_ ## func ## _wrapper \
394 : { \
395 : typedef rettype (*type) parameters; \
396 : \
397 : inline operator type () const \
398 : { \
399 : return ::rpl_func; \
400 : } \
401 : } func = {}; \
402 : } \
403 : _GL_EXTERN_C int _gl_cxxalias_dummy
404 : #else
405 : # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
406 : _GL_EXTERN_C int _gl_cxxalias_dummy
407 : #endif
408 :
409 : /* _GL_CXXALIAS_MDA (func, rettype, parameters);
410 : is to be used when func is a Microsoft deprecated alias, on native Windows.
411 : It declares a C++ alias called GNULIB_NAMESPACE::func
412 : that redirects to _func, if GNULIB_NAMESPACE is defined.
413 : Example:
414 : _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
415 : */
416 : #define _GL_CXXALIAS_MDA(func,rettype,parameters) \
417 : _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
418 :
419 : /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
420 : is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
421 : except that the C function rpl_func may have a slightly different
422 : declaration. A cast is used to silence the "invalid conversion" error
423 : that would otherwise occur. */
424 : #if defined __cplusplus && defined GNULIB_NAMESPACE
425 : # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
426 : namespace GNULIB_NAMESPACE \
427 : { \
428 : static const struct _gl_ ## func ## _wrapper \
429 : { \
430 : typedef rettype (*type) parameters; \
431 : \
432 : inline operator type () const \
433 : { \
434 : return reinterpret_cast<type>(::rpl_func); \
435 : } \
436 : } func = {}; \
437 : } \
438 : _GL_EXTERN_C int _gl_cxxalias_dummy
439 : #else
440 : # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
441 : _GL_EXTERN_C int _gl_cxxalias_dummy
442 : #endif
443 :
444 : /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
445 : is like _GL_CXXALIAS_MDA (func, rettype, parameters);
446 : except that the C function func may have a slightly different declaration.
447 : A cast is used to silence the "invalid conversion" error that would
448 : otherwise occur. */
449 : #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
450 : _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
451 :
452 : /* _GL_CXXALIAS_SYS (func, rettype, parameters);
453 : declares a C++ alias called GNULIB_NAMESPACE::func
454 : that redirects to the system provided function func, if GNULIB_NAMESPACE
455 : is defined.
456 : Example:
457 : _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
458 :
459 : Wrapping func in an object with an inline conversion operator
460 : avoids a reference to func unless GNULIB_NAMESPACE::func is
461 : actually used in the program. */
462 : #if defined __cplusplus && defined GNULIB_NAMESPACE
463 : # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
464 : namespace GNULIB_NAMESPACE \
465 : { \
466 : static const struct _gl_ ## func ## _wrapper \
467 : { \
468 : typedef rettype (*type) parameters; \
469 : \
470 : inline operator type () const \
471 : { \
472 : return ::func; \
473 : } \
474 : } func = {}; \
475 : } \
476 : _GL_EXTERN_C int _gl_cxxalias_dummy
477 : #else
478 : # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
479 : _GL_EXTERN_C int _gl_cxxalias_dummy
480 : #endif
481 :
482 : /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
483 : is like _GL_CXXALIAS_SYS (func, rettype, parameters);
484 : except that the C function func may have a slightly different declaration.
485 : A cast is used to silence the "invalid conversion" error that would
486 : otherwise occur. */
487 : #if defined __cplusplus && defined GNULIB_NAMESPACE
488 : # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
489 : namespace GNULIB_NAMESPACE \
490 : { \
491 : static const struct _gl_ ## func ## _wrapper \
492 : { \
493 : typedef rettype (*type) parameters; \
494 : \
495 : inline operator type () const \
496 : { \
497 : return reinterpret_cast<type>(::func); \
498 : } \
499 : } func = {}; \
500 : } \
501 : _GL_EXTERN_C int _gl_cxxalias_dummy
502 : #else
503 : # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
504 : _GL_EXTERN_C int _gl_cxxalias_dummy
505 : #endif
506 :
507 : /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
508 : is like _GL_CXXALIAS_SYS (func, rettype, parameters);
509 : except that the C function is picked among a set of overloaded functions,
510 : namely the one with rettype2 and parameters2. Two consecutive casts
511 : are used to silence the "cannot find a match" and "invalid conversion"
512 : errors that would otherwise occur. */
513 : #if defined __cplusplus && defined GNULIB_NAMESPACE
514 : /* The outer cast must be a reinterpret_cast.
515 : The inner cast: When the function is defined as a set of overloaded
516 : functions, it works as a static_cast<>, choosing the designated variant.
517 : When the function is defined as a single variant, it works as a
518 : reinterpret_cast<>. The parenthesized cast syntax works both ways. */
519 : # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
520 : namespace GNULIB_NAMESPACE \
521 : { \
522 : static const struct _gl_ ## func ## _wrapper \
523 : { \
524 : typedef rettype (*type) parameters; \
525 : \
526 : inline operator type () const \
527 : { \
528 : return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
529 : } \
530 : } func = {}; \
531 : } \
532 : _GL_EXTERN_C int _gl_cxxalias_dummy
533 : #else
534 : # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
535 : _GL_EXTERN_C int _gl_cxxalias_dummy
536 : #endif
537 :
538 : /* _GL_CXXALIASWARN (func);
539 : causes a warning to be emitted when ::func is used but not when
540 : GNULIB_NAMESPACE::func is used. func must be defined without overloaded
541 : variants. */
542 : #if defined __cplusplus && defined GNULIB_NAMESPACE
543 : # define _GL_CXXALIASWARN(func) \
544 : _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
545 : # define _GL_CXXALIASWARN_1(func,namespace) \
546 : _GL_CXXALIASWARN_2 (func, namespace)
547 : /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
548 : we enable the warning only when not optimizing. */
549 : # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
550 : # define _GL_CXXALIASWARN_2(func,namespace) \
551 : _GL_WARN_ON_USE (func, \
552 : "The symbol ::" #func " refers to the system function. " \
553 : "Use " #namespace "::" #func " instead.")
554 : # elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
555 : # define _GL_CXXALIASWARN_2(func,namespace) \
556 : extern __typeof__ (func) func
557 : # else
558 : # define _GL_CXXALIASWARN_2(func,namespace) \
559 : _GL_EXTERN_C int _gl_cxxalias_dummy
560 : # endif
561 : #else
562 : # define _GL_CXXALIASWARN(func) \
563 : _GL_EXTERN_C int _gl_cxxalias_dummy
564 : #endif
565 :
566 : /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
567 : causes a warning to be emitted when the given overloaded variant of ::func
568 : is used but not when GNULIB_NAMESPACE::func is used. */
569 : #if defined __cplusplus && defined GNULIB_NAMESPACE
570 : # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
571 : _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
572 : GNULIB_NAMESPACE)
573 : # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
574 : _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
575 : /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
576 : we enable the warning only when not optimizing. */
577 : # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
578 : # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
579 : _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
580 : "The symbol ::" #func " refers to the system function. " \
581 : "Use " #namespace "::" #func " instead.")
582 : # else
583 : # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
584 : _GL_EXTERN_C int _gl_cxxalias_dummy
585 : # endif
586 : #else
587 : # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
588 : _GL_EXTERN_C int _gl_cxxalias_dummy
589 : #endif
590 :
591 : #endif /* _GL_CXXDEFS_H */
592 :
593 : /* The definition of _GL_ARG_NONNULL is copied here. */
594 : /* A C macro for declaring that specific arguments must not be NULL.
595 : Copyright (C) 2009-2025 Free Software Foundation, Inc.
596 :
597 : This program is free software: you can redistribute it and/or modify it
598 : under the terms of the GNU Lesser General Public License as published
599 : by the Free Software Foundation; either version 2 of the License, or
600 : (at your option) any later version.
601 :
602 : This program is distributed in the hope that it will be useful,
603 : but WITHOUT ANY WARRANTY; without even the implied warranty of
604 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
605 : Lesser General Public License for more details.
606 :
607 : You should have received a copy of the GNU Lesser General Public License
608 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
609 :
610 : /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
611 : that the values passed as arguments n, ..., m must be non-NULL pointers.
612 : n = 1 stands for the first argument, n = 2 for the second argument etc. */
613 : #ifndef _GL_ARG_NONNULL
614 : # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
615 : # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
616 : # else
617 : # define _GL_ARG_NONNULL(params)
618 : # endif
619 : #endif
620 :
621 : /* The definition of _GL_WARN_ON_USE is copied here. */
622 : /* A C macro for emitting warnings if a function is used.
623 : Copyright (C) 2010-2025 Free Software Foundation, Inc.
624 :
625 : This program is free software: you can redistribute it and/or modify it
626 : under the terms of the GNU Lesser General Public License as published
627 : by the Free Software Foundation; either version 2 of the License, or
628 : (at your option) any later version.
629 :
630 : This program is distributed in the hope that it will be useful,
631 : but WITHOUT ANY WARRANTY; without even the implied warranty of
632 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
633 : Lesser General Public License for more details.
634 :
635 : You should have received a copy of the GNU Lesser General Public License
636 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
637 :
638 : /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
639 : for FUNCTION which will then trigger a compiler warning containing
640 : the text of "literal string" anywhere that function is called, if
641 : supported by the compiler. If the compiler does not support this
642 : feature, the macro expands to an unused extern declaration.
643 :
644 : _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
645 : attribute used in _GL_WARN_ON_USE. If the compiler does not support
646 : this feature, it expands to empty.
647 :
648 : These macros are useful for marking a function as a potential
649 : portability trap, with the intent that "literal string" include
650 : instructions on the replacement function that should be used
651 : instead.
652 : _GL_WARN_ON_USE is for functions with 'extern' linkage.
653 : _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
654 : linkage.
655 :
656 : _GL_WARN_ON_USE should not be used more than once for a given function
657 : in a given compilation unit (because this may generate a warning even
658 : if the function is never called).
659 :
660 : However, one of the reasons that a function is a portability trap is
661 : if it has the wrong signature. Declaring FUNCTION with a different
662 : signature in C is a compilation error, so this macro must use the
663 : same type as any existing declaration so that programs that avoid
664 : the problematic FUNCTION do not fail to compile merely because they
665 : included a header that poisoned the function. But this implies that
666 : _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
667 : have a declaration. Use of this macro implies that there must not
668 : be any other macro hiding the declaration of FUNCTION; but
669 : undefining FUNCTION first is part of the poisoning process anyway
670 : (although for symbols that are provided only via a macro, the result
671 : is a compilation error rather than a warning containing
672 : "literal string"). Also note that in C++, it is only safe to use if
673 : FUNCTION has no overloads.
674 :
675 : For an example, it is possible to poison 'getline' by:
676 : - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
677 : [getline]) in configure.ac, which potentially defines
678 : HAVE_RAW_DECL_GETLINE
679 : - adding this code to a header that wraps the system <stdio.h>:
680 : #undef getline
681 : #if HAVE_RAW_DECL_GETLINE
682 : _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
683 : "not universally present; use the gnulib module getline");
684 : #endif
685 :
686 : It is not possible to directly poison global variables. But it is
687 : possible to write a wrapper accessor function, and poison that
688 : (less common usage, like &environ, will cause a compilation error
689 : rather than issue the nice warning, but the end result of informing
690 : the developer about their portability problem is still achieved):
691 : #if HAVE_RAW_DECL_ENVIRON
692 : static char ***
693 : rpl_environ (void) { return &environ; }
694 : _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
695 : # undef environ
696 : # define environ (*rpl_environ ())
697 : #endif
698 : or better (avoiding contradictory use of 'static' and 'extern'):
699 : #if HAVE_RAW_DECL_ENVIRON
700 : static char ***
701 : _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
702 : rpl_environ (void) { return &environ; }
703 : # undef environ
704 : # define environ (*rpl_environ ())
705 : #endif
706 : */
707 : #ifndef _GL_WARN_ON_USE
708 :
709 : # if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
710 : /* A compiler attribute is available in gcc versions 4.3.0 and later. */
711 : # define _GL_WARN_ON_USE(function, message) \
712 : _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
713 : # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
714 : __attribute__ ((__warning__ (message)))
715 : # elif __clang_major__ >= 4
716 : /* Another compiler attribute is available in clang. */
717 : # define _GL_WARN_ON_USE(function, message) \
718 : _GL_WARN_EXTERN_C __typeof__ (function) function \
719 : __attribute__ ((__diagnose_if__ (1, message, "warning")))
720 : # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
721 : __attribute__ ((__diagnose_if__ (1, message, "warning")))
722 : # elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
723 : /* Verify the existence of the function. */
724 : # define _GL_WARN_ON_USE(function, message) \
725 : _GL_WARN_EXTERN_C __typeof__ (function) function
726 : # define _GL_WARN_ON_USE_ATTRIBUTE(message)
727 : # else /* Unsupported. */
728 : # define _GL_WARN_ON_USE(function, message) \
729 : _GL_WARN_EXTERN_C int _gl_warn_on_use
730 : # define _GL_WARN_ON_USE_ATTRIBUTE(message)
731 : # endif
732 : #endif
733 :
734 : /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
735 : is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
736 : function is declared with the given prototype, consisting of return type,
737 : parameters, and attributes.
738 : This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
739 : not work in this case. */
740 : #ifndef _GL_WARN_ON_USE_CXX
741 : # if !defined __cplusplus
742 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
743 : _GL_WARN_ON_USE (function, msg)
744 : # else
745 : # if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
746 : /* A compiler attribute is available in gcc versions 4.3.0 and later. */
747 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
748 : extern rettype_gcc function parameters_and_attributes \
749 : __attribute__ ((__warning__ (msg)))
750 : # elif __clang_major__ >= 4
751 : /* Another compiler attribute is available in clang. */
752 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
753 : extern rettype_clang function parameters_and_attributes \
754 : __attribute__ ((__diagnose_if__ (1, msg, "warning")))
755 : # elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
756 : /* Verify the existence of the function. */
757 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
758 : extern rettype_gcc function parameters_and_attributes
759 : # else /* Unsupported. */
760 : # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
761 : _GL_WARN_EXTERN_C int _gl_warn_on_use
762 : # endif
763 : # endif
764 : #endif
765 :
766 : /* _GL_WARN_EXTERN_C declaration;
767 : performs the declaration with C linkage. */
768 : #ifndef _GL_WARN_EXTERN_C
769 : # if defined __cplusplus
770 : # define _GL_WARN_EXTERN_C extern "C"
771 : # else
772 : # define _GL_WARN_EXTERN_C extern
773 : # endif
774 : #endif
775 :
776 : /* Macros for stringification. */
777 : #define _GL_STDIO_STRINGIZE(token) #token
778 : #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
779 :
780 : /* When also using extern inline, suppress the use of static inline in
781 : standard headers of problematic Apple configurations, as Libc at
782 : least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
783 : <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
784 : Perhaps Apple will fix this some day. */
785 : #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
786 : && defined __GNUC__ && defined __STDC__)
787 : # undef putc_unlocked
788 : #endif
789 :
790 :
791 : /* Maximum number of characters produced by printing a NaN value. */
792 : #ifndef _PRINTF_NAN_LEN_MAX
793 : # if defined __FreeBSD__ || defined __DragonFly__ \
794 : || defined __NetBSD__ \
795 : || (defined __APPLE__ && defined __MACH__)
796 : /* On BSD systems, a NaN value prints as just "nan", without a sign. */
797 : # define _PRINTF_NAN_LEN_MAX 3
798 : # elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__
799 : /* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */
800 : # define _PRINTF_NAN_LEN_MAX 4
801 : # elif defined _AIX
802 : /* AIX produces "[-]NaNQ". */
803 : # define _PRINTF_NAN_LEN_MAX 5
804 : # elif defined _WIN32 && !defined __CYGWIN__
805 : /* On native Windows, the output can be:
806 : - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
807 : - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */
808 : # define _PRINTF_NAN_LEN_MAX 10
809 : # elif defined __sgi
810 : /* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal
811 : digits. */
812 : # define _PRINTF_NAN_LEN_MAX 14
813 : # else
814 : /* We don't know, but 32 should be a safe maximum. */
815 : # define _PRINTF_NAN_LEN_MAX 32
816 : # endif
817 : #endif
818 :
819 :
820 : #if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
821 : /* Workarounds against msvcrt bugs. */
822 : _GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t,
823 : (const void *ptr, size_t size, size_t nmemb, FILE *fp),
824 : _GL_ARG_NONNULL ((1, 4)));
825 : # if defined __MINGW32__
826 : _GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int,
827 : (FILE *restrict fp, const char *restrict format, ...),
828 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
829 : _GL_ARG_NONNULL ((1, 2)));
830 : _GL_FUNCDECL_SYS (gl_consolesafe_printf, int,
831 : (const char *restrict format, ...),
832 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
833 : _GL_ARG_NONNULL ((1)));
834 : _GL_FUNCDECL_SYS (gl_consolesafe_vfprintf, int,
835 : (FILE *restrict fp,
836 : const char *restrict format, va_list args),
837 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
838 : _GL_ARG_NONNULL ((1, 2)));
839 : _GL_FUNCDECL_SYS (gl_consolesafe_vprintf, int,
840 : (const char *restrict format, va_list args),
841 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
842 : _GL_ARG_NONNULL ((1)));
843 : # endif
844 : #endif
845 :
846 :
847 : #if 0
848 : /* Prints formatted output to file descriptor FD.
849 : Returns the number of bytes written to the file descriptor. Upon
850 : failure, returns -1 with errno set.
851 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
852 : Therefore, if the format string is valid and does not use %ls/%lc
853 : directives nor widths, the only possible failure codes are ENOMEM
854 : and the possible failure codes from write(), excluding EINTR. */
855 : _GL_FUNCDECL_SYS (dzprintf, off64_t,
856 : (int fd, const char *restrict format, ...),
857 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
858 : _GL_ARG_NONNULL ((2)));
859 : _GL_CXXALIAS_SYS (dzprintf, off64_t,
860 : (int fd, const char *restrict format, ...));
861 : #endif
862 :
863 : #if 0
864 : /* Prints formatted output to file descriptor FD.
865 : Returns the number of bytes written to the file descriptor. Upon
866 : failure, returns a negative value. */
867 : # if 0
868 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
869 : # define dprintf rpl_dprintf
870 : # endif
871 : _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...),
872 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
873 : _GL_ARG_NONNULL ((2)));
874 : _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
875 : # else
876 : # if !1
877 : _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...),
878 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
879 : _GL_ARG_NONNULL ((2)));
880 : # endif
881 : _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
882 : # endif
883 : # if __GLIBC__ >= 2
884 : _GL_CXXALIASWARN (dprintf);
885 : # endif
886 : #elif defined GNULIB_POSIXCHECK
887 : # undef dprintf
888 : # if HAVE_RAW_DECL_DPRINTF
889 : _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
890 : "use gnulib module dprintf for portability");
891 : # endif
892 : #endif
893 :
894 : #if 0
895 : /* Close STREAM and its underlying file descriptor. */
896 : # if 0
897 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
898 : # define fclose rpl_fclose
899 : # endif
900 : _GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
901 : _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
902 : # else
903 : _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
904 : # endif
905 : # if __GLIBC__ >= 2
906 : _GL_CXXALIASWARN (fclose);
907 : # endif
908 : #elif defined GNULIB_POSIXCHECK
909 : # undef fclose
910 : /* Assume fclose is always declared. */
911 : _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
912 : "use gnulib module fclose for portable POSIX compliance");
913 : #endif
914 :
915 : #if 1
916 : /* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
917 : not required. In C++ with GNULIB_NAMESPACE, avoid differences between
918 : platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
919 : it. */
920 : # if defined _WIN32 && !defined __CYGWIN__
921 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
922 : # undef fcloseall
923 : # define fcloseall _fcloseall
924 : # endif
925 : _GL_CXXALIAS_MDA (fcloseall, int, (void));
926 : # else
927 : # if 1
928 : # if defined __FreeBSD__ || defined __DragonFly__
929 : _GL_CXXALIAS_SYS (fcloseall, void, (void));
930 : # else
931 : _GL_CXXALIAS_SYS (fcloseall, int, (void));
932 : # endif
933 : # endif
934 : # endif
935 : # if (defined _WIN32 && !defined __CYGWIN__) || 1
936 : _GL_CXXALIASWARN (fcloseall);
937 : # endif
938 : #endif
939 :
940 : #if 0
941 : # if 0
942 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
943 : # undef fdopen
944 : # define fdopen rpl_fdopen
945 : # endif
946 : _GL_FUNCDECL_RPL (fdopen, FILE *,
947 : (int fd, const char *mode),
948 : _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
949 : _GL_ATTRIBUTE_MALLOC
950 : _GL_ATTRIBUTE_NODISCARD);
951 : _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
952 : # elif defined _WIN32 && !defined __CYGWIN__
953 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
954 : # undef fdopen
955 : # define fdopen _fdopen
956 : # endif
957 : _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
958 : # else
959 : # if __GNUC__ >= 11 && !defined __clang__
960 : /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
961 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
962 : _GL_FUNCDECL_SYS (fdopen, FILE *,
963 : (int fd, const char *mode),
964 : _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
965 : _GL_ATTRIBUTE_MALLOC
966 : _GL_ATTRIBUTE_NODISCARD)
967 : _GL_ATTRIBUTE_NOTHROW;
968 : # else
969 : _GL_FUNCDECL_SYS (fdopen, FILE *,
970 : (int fd, const char *mode),
971 : _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
972 : _GL_ATTRIBUTE_MALLOC
973 : _GL_ATTRIBUTE_NODISCARD);
974 : # endif
975 : # endif
976 : _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
977 : # endif
978 : _GL_CXXALIASWARN (fdopen);
979 : #else
980 : # if 0 && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen
981 : /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
982 : # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
983 : _GL_FUNCDECL_SYS (fdopen, FILE *,
984 : (int fd, const char *mode),
985 : _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
986 : _GL_ATTRIBUTE_MALLOC)
987 : _GL_ATTRIBUTE_NOTHROW;
988 : # else
989 : _GL_FUNCDECL_SYS (fdopen, FILE *,
990 : (int fd, const char *mode),
991 : _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
992 : _GL_ATTRIBUTE_MALLOC);
993 : # endif
994 : # endif
995 : # if defined GNULIB_POSIXCHECK
996 : # undef fdopen
997 : /* Assume fdopen is always declared. */
998 : _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
999 : "use gnulib module fdopen for portability");
1000 : # elif 1
1001 : /* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
1002 : required. In C++ with GNULIB_NAMESPACE, avoid differences between
1003 : platforms by defining GNULIB_NAMESPACE::fdopen always. */
1004 : # if defined _WIN32 && !defined __CYGWIN__
1005 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1006 : # undef fdopen
1007 : # define fdopen _fdopen
1008 : # endif
1009 : _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
1010 : # else
1011 : _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
1012 : # endif
1013 : _GL_CXXALIASWARN (fdopen);
1014 : # endif
1015 : #endif
1016 :
1017 : #if 0
1018 : /* Flush all pending data on STREAM according to POSIX rules. Both
1019 : output and seekable input streams are supported.
1020 : Note! LOSS OF DATA can occur if fflush is applied on an input stream
1021 : that is _not_seekable_ or on an update stream that is _not_seekable_
1022 : and in which the most recent operation was input. Seekability can
1023 : be tested with lseek(fileno(fp),0,SEEK_CUR). */
1024 : # if 0
1025 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1026 : # define fflush rpl_fflush
1027 : # endif
1028 : _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream), );
1029 : _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
1030 : # else
1031 : _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
1032 : # endif
1033 : # if __GLIBC__ >= 2
1034 : _GL_CXXALIASWARN (fflush);
1035 : # endif
1036 : #elif defined GNULIB_POSIXCHECK
1037 : # undef fflush
1038 : /* Assume fflush is always declared. */
1039 : _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
1040 : "use gnulib module fflush for portable POSIX compliance");
1041 : #endif
1042 :
1043 : #if 1
1044 : # if 0 && 0
1045 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1046 : # undef fgetc
1047 : # define fgetc rpl_fgetc
1048 : # endif
1049 : _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
1050 : _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
1051 : # else
1052 : _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
1053 : # endif
1054 : # if __GLIBC__ >= 2
1055 : _GL_CXXALIASWARN (fgetc);
1056 : # endif
1057 : #endif
1058 :
1059 : #if 1
1060 : # if 0 && 0
1061 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1062 : # undef fgets
1063 : # define fgets rpl_fgets
1064 : # endif
1065 : _GL_FUNCDECL_RPL (fgets, char *,
1066 : (char *restrict s, int n, FILE *restrict stream),
1067 : _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
1068 : _GL_CXXALIAS_RPL (fgets, char *,
1069 : (char *restrict s, int n, FILE *restrict stream));
1070 : # else
1071 : _GL_CXXALIAS_SYS (fgets, char *,
1072 : (char *restrict s, int n, FILE *restrict stream));
1073 : # endif
1074 : # if __GLIBC__ >= 2
1075 : _GL_CXXALIASWARN (fgets);
1076 : # endif
1077 : #endif
1078 :
1079 : #if 1
1080 : /* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
1081 : required. In C++ with GNULIB_NAMESPACE, avoid differences between
1082 : platforms by defining GNULIB_NAMESPACE::fileno always. */
1083 : # if defined _WIN32 && !defined __CYGWIN__
1084 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085 : # undef fileno
1086 : # define fileno _fileno
1087 : # endif
1088 : _GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream));
1089 : # else
1090 : _GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream));
1091 : # endif
1092 : _GL_CXXALIASWARN (fileno);
1093 : #endif
1094 :
1095 : #if 0
1096 : # if (0 && 0) \
1097 : || (0 && 0)
1098 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1099 : # undef fopen
1100 : # define fopen rpl_fopen
1101 : # endif
1102 : _GL_FUNCDECL_RPL (fopen, FILE *,
1103 : (const char *restrict filename, const char *restrict mode),
1104 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1105 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1106 : _GL_CXXALIAS_RPL (fopen, FILE *,
1107 : (const char *restrict filename, const char *restrict mode));
1108 : # else
1109 : # if __GNUC__ >= 11 && !defined __clang__
1110 : /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
1111 : _GL_FUNCDECL_SYS (fopen, FILE *,
1112 : (const char *restrict filename, const char *restrict mode),
1113 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1114 : _GL_ATTRIBUTE_NODISCARD);
1115 : # endif
1116 : _GL_CXXALIAS_SYS (fopen, FILE *,
1117 : (const char *restrict filename, const char *restrict mode));
1118 : # endif
1119 : # if __GLIBC__ >= 2
1120 : _GL_CXXALIASWARN (fopen);
1121 : # endif
1122 : #else
1123 : # if 0 && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen
1124 : /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
1125 : _GL_FUNCDECL_SYS (fopen, FILE *,
1126 : (const char *restrict filename, const char *restrict mode),
1127 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1128 : # endif
1129 : # if defined GNULIB_POSIXCHECK
1130 : # undef fopen
1131 : /* Assume fopen is always declared. */
1132 : _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
1133 : "use gnulib module fopen for portability");
1134 : # endif
1135 : #endif
1136 :
1137 : #if 0
1138 : /* Prints formatted output to stream FP.
1139 : Returns the number of bytes written to the stream. Upon failure,
1140 : returns -1 with the stream's error indicator set.
1141 : Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1142 : Therefore, if the format string is valid and does not use %ls/%lc
1143 : directives nor widths, the only possible failure causes are ENOMEM
1144 : and the possible failure causes from fwrite(). */
1145 : _GL_FUNCDECL_SYS (fzprintf, off64_t,
1146 : (FILE *restrict fp, const char *restrict format, ...),
1147 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1148 : _GL_ARG_NONNULL ((1, 2)));
1149 : _GL_CXXALIAS_SYS (fzprintf, off64_t,
1150 : (FILE *restrict fp, const char *restrict format, ...));
1151 : #endif
1152 :
1153 : #if 1 || 1
1154 : /* Prints formatted output to stream FP.
1155 : Returns the number of bytes written to the stream. Upon failure,
1156 : returns a negative value with the stream's error indicator set. */
1157 : # if (1 && 1) \
1158 : || (1 && 0 && (0 || 0))
1159 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1160 : # define fprintf rpl_fprintf
1161 : # endif
1162 : # define GNULIB_overrides_fprintf 1
1163 : # if 1 || 0
1164 : _GL_FUNCDECL_RPL (fprintf, int,
1165 : (FILE *restrict fp, const char *restrict format, ...),
1166 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1167 : _GL_ARG_NONNULL ((1, 2)));
1168 : # else
1169 : _GL_FUNCDECL_RPL (fprintf, int,
1170 : (FILE *restrict fp, const char *restrict format, ...),
1171 : _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
1172 : _GL_ARG_NONNULL ((1, 2)));
1173 : # endif
1174 : _GL_CXXALIAS_RPL (fprintf, int,
1175 : (FILE *restrict fp, const char *restrict format, ...));
1176 : # else
1177 : _GL_CXXALIAS_SYS (fprintf, int,
1178 : (FILE *restrict fp, const char *restrict format, ...));
1179 : # endif
1180 : # if __GLIBC__ >= 2
1181 : _GL_CXXALIASWARN (fprintf);
1182 : # endif
1183 : #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1184 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1185 : # undef fprintf
1186 : # define fprintf gl_consolesafe_fprintf
1187 : # endif
1188 : #endif
1189 : #if !1 && defined GNULIB_POSIXCHECK
1190 : # if !GNULIB_overrides_fprintf
1191 : # undef fprintf
1192 : # endif
1193 : /* Assume fprintf is always declared. */
1194 : _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
1195 : "use gnulib module fprintf-posix for portable "
1196 : "POSIX compliance");
1197 : #endif
1198 :
1199 : #if 0
1200 : /* Discard all pending buffered I/O data on STREAM.
1201 : STREAM must not be wide-character oriented.
1202 : When discarding pending output, the file position is set back to where it
1203 : was before the write calls. When discarding pending input, the file
1204 : position is advanced to match the end of the previously read input.
1205 : Return 0 if successful. Upon error, return -1 and set errno. */
1206 : # if 0
1207 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1208 : # define fpurge rpl_fpurge
1209 : # endif
1210 : _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
1211 : _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
1212 : # else
1213 : # if !1
1214 : _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
1215 : # endif
1216 : _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
1217 : # endif
1218 : # if __GLIBC__ >= 2
1219 : _GL_CXXALIASWARN (fpurge);
1220 : # endif
1221 : #elif defined GNULIB_POSIXCHECK
1222 : # undef fpurge
1223 : # if HAVE_RAW_DECL_FPURGE
1224 : _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
1225 : "use gnulib module fpurge for portability");
1226 : # endif
1227 : #endif
1228 :
1229 : #if 1
1230 : # if 0 && (0 || 0)
1231 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1232 : # undef fputc
1233 : # define fputc rpl_fputc
1234 : # endif
1235 : _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
1236 : _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
1237 : # else
1238 : _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
1239 : # endif
1240 : # if __GLIBC__ >= 2
1241 : _GL_CXXALIASWARN (fputc);
1242 : # endif
1243 : #endif
1244 :
1245 : #if 1
1246 : # if 0 && (0 || 0)
1247 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1248 : # undef fputs
1249 : # define fputs rpl_fputs
1250 : # endif
1251 : _GL_FUNCDECL_RPL (fputs, int,
1252 : (const char *restrict string, FILE *restrict stream),
1253 : _GL_ARG_NONNULL ((1, 2)));
1254 : _GL_CXXALIAS_RPL (fputs, int,
1255 : (const char *restrict string, FILE *restrict stream));
1256 : # else
1257 : _GL_CXXALIAS_SYS (fputs, int,
1258 : (const char *restrict string, FILE *restrict stream));
1259 : # endif
1260 : # if __GLIBC__ >= 2
1261 : _GL_CXXALIASWARN (fputs);
1262 : # endif
1263 : #endif
1264 :
1265 : #if 1
1266 : # if 0 && 0
1267 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1268 : # undef fread
1269 : # define fread rpl_fread
1270 : # endif
1271 : _GL_FUNCDECL_RPL (fread, size_t,
1272 : (void *restrict ptr, size_t s, size_t n,
1273 : FILE *restrict stream),
1274 : _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD);
1275 : _GL_CXXALIAS_RPL (fread, size_t,
1276 : (void *restrict ptr, size_t s, size_t n,
1277 : FILE *restrict stream));
1278 : # else
1279 : _GL_CXXALIAS_SYS (fread, size_t,
1280 : (void *restrict ptr, size_t s, size_t n,
1281 : FILE *restrict stream));
1282 : # endif
1283 : # if __GLIBC__ >= 2
1284 : _GL_CXXALIASWARN (fread);
1285 : # endif
1286 : #endif
1287 :
1288 : #if 0
1289 : # if 0
1290 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1291 : # undef freopen
1292 : # define freopen rpl_freopen
1293 : # endif
1294 : _GL_FUNCDECL_RPL (freopen, FILE *,
1295 : (const char *restrict filename, const char *restrict mode,
1296 : FILE *restrict stream),
1297 : _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
1298 : _GL_CXXALIAS_RPL (freopen, FILE *,
1299 : (const char *restrict filename, const char *restrict mode,
1300 : FILE *restrict stream));
1301 : # else
1302 : _GL_CXXALIAS_SYS (freopen, FILE *,
1303 : (const char *restrict filename, const char *restrict mode,
1304 : FILE *restrict stream));
1305 : # endif
1306 : # if __GLIBC__ >= 2
1307 : _GL_CXXALIASWARN (freopen);
1308 : # endif
1309 : #elif defined GNULIB_POSIXCHECK
1310 : # undef freopen
1311 : /* Assume freopen is always declared. */
1312 : _GL_WARN_ON_USE (freopen,
1313 : "freopen on native Windows platforms is not POSIX compliant - "
1314 : "use gnulib module freopen for portability");
1315 : #endif
1316 :
1317 : #if 1
1318 : # if 0 && 0
1319 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1320 : # undef fscanf
1321 : # define fscanf rpl_fscanf
1322 : # endif
1323 : _GL_FUNCDECL_RPL (fscanf, int,
1324 : (FILE *restrict stream, const char *restrict format, ...),
1325 : _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
1326 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1327 : _GL_CXXALIAS_RPL (fscanf, int,
1328 : (FILE *restrict stream, const char *restrict format, ...));
1329 : # else
1330 : _GL_CXXALIAS_SYS (fscanf, int,
1331 : (FILE *restrict stream, const char *restrict format, ...));
1332 : # endif
1333 : # if __GLIBC__ >= 2
1334 : _GL_CXXALIASWARN (fscanf);
1335 : # endif
1336 : #endif
1337 :
1338 :
1339 : /* Set up the following warnings, based on which modules are in use.
1340 : GNU Coding Standards discourage the use of fseek, since it imposes
1341 : an arbitrary limitation on some 32-bit hosts. Remember that the
1342 : fseek module depends on the fseeko module, so we only have three
1343 : cases to consider:
1344 :
1345 : 1. The developer is not using either module. Issue a warning under
1346 : GNULIB_POSIXCHECK for both functions, to remind them that both
1347 : functions have bugs on some systems. _GL_NO_LARGE_FILES has no
1348 : impact on this warning.
1349 :
1350 : 2. The developer is using both modules. They may be unaware of the
1351 : arbitrary limitations of fseek, so issue a warning under
1352 : GNULIB_POSIXCHECK. On the other hand, they may be using both
1353 : modules intentionally, so the developer can define
1354 : _GL_NO_LARGE_FILES in the compilation units where the use of fseek
1355 : is safe, to silence the warning.
1356 :
1357 : 3. The developer is using the fseeko module, but not fseek. Gnulib
1358 : guarantees that fseek will still work around platform bugs in that
1359 : case, but we presume that the developer is aware of the pitfalls of
1360 : fseek and was trying to avoid it, so issue a warning even when
1361 : GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
1362 : defined to silence the warning in particular compilation units.
1363 : In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
1364 : fseek gets defined as a macro, it is recommended that the developer
1365 : uses the fseek module, even if he is not calling the fseek function.
1366 :
1367 : Most gnulib clients that perform stream operations should fall into
1368 : category 3. */
1369 :
1370 : #if 0
1371 : # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
1372 : # define _GL_FSEEK_WARN /* Category 2, above. */
1373 : # undef fseek
1374 : # endif
1375 : # if 0
1376 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1377 : # undef fseek
1378 : # define fseek rpl_fseek
1379 : # endif
1380 : _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence),
1381 : _GL_ARG_NONNULL ((1)));
1382 : _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
1383 : # else
1384 : _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
1385 : # endif
1386 : # if __GLIBC__ >= 2
1387 : _GL_CXXALIASWARN (fseek);
1388 : # endif
1389 : #endif
1390 :
1391 : #if 0
1392 : # if !0 && !defined _GL_NO_LARGE_FILES
1393 : # define _GL_FSEEK_WARN /* Category 3, above. */
1394 : # undef fseek
1395 : # endif
1396 : # if 0
1397 : /* Provide an fseeko function that is aware of a preceding fflush(), and which
1398 : detects pipes. */
1399 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1400 : # undef fseeko
1401 : # define fseeko rpl_fseeko
1402 : # endif
1403 : _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence),
1404 : _GL_ARG_NONNULL ((1)));
1405 : _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
1406 : # else
1407 : # if ! 1
1408 : _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence),
1409 : _GL_ARG_NONNULL ((1)));
1410 : # endif
1411 : _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
1412 : # endif
1413 : _GL_CXXALIASWARN (fseeko);
1414 : #elif defined GNULIB_POSIXCHECK
1415 : # define _GL_FSEEK_WARN /* Category 1, above. */
1416 : # undef fseek
1417 : # undef fseeko
1418 : # if HAVE_RAW_DECL_FSEEKO
1419 : _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
1420 : "use gnulib module fseeko for portability");
1421 : # endif
1422 : #endif
1423 :
1424 : #ifdef _GL_FSEEK_WARN
1425 : # undef _GL_FSEEK_WARN
1426 : /* Here, either fseek is undefined (but C89 guarantees that it is
1427 : declared), or it is defined as rpl_fseek (declared above). */
1428 : _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
1429 : "on 32-bit platforms - "
1430 : "use fseeko function for handling of large files");
1431 : #endif
1432 :
1433 :
1434 : /* ftell, ftello. See the comments on fseek/fseeko. */
1435 :
1436 : #if 0
1437 : # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
1438 : # define _GL_FTELL_WARN /* Category 2, above. */
1439 : # undef ftell
1440 : # endif
1441 : # if 0
1442 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1443 : # undef ftell
1444 : # define ftell rpl_ftell
1445 : # endif
1446 : _GL_FUNCDECL_RPL (ftell, long, (FILE *fp),
1447 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1448 : _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
1449 : # else
1450 : _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
1451 : # endif
1452 : # if __GLIBC__ >= 2
1453 : _GL_CXXALIASWARN (ftell);
1454 : # endif
1455 : #endif
1456 :
1457 : #if 0
1458 : # if !0 && !defined _GL_NO_LARGE_FILES
1459 : # define _GL_FTELL_WARN /* Category 3, above. */
1460 : # undef ftell
1461 : # endif
1462 : # if 0
1463 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1464 : # undef ftello
1465 : # define ftello rpl_ftello
1466 : # endif
1467 : _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp),
1468 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1469 : _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
1470 : # else
1471 : # if ! 1
1472 : _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp),
1473 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1474 : # endif
1475 : _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
1476 : # endif
1477 : _GL_CXXALIASWARN (ftello);
1478 : #elif defined GNULIB_POSIXCHECK
1479 : # define _GL_FTELL_WARN /* Category 1, above. */
1480 : # undef ftell
1481 : # undef ftello
1482 : # if HAVE_RAW_DECL_FTELLO
1483 : _GL_WARN_ON_USE (ftello, "ftello is unportable - "
1484 : "use gnulib module ftello for portability");
1485 : # endif
1486 : #endif
1487 :
1488 : #ifdef _GL_FTELL_WARN
1489 : # undef _GL_FTELL_WARN
1490 : /* Here, either ftell is undefined (but C89 guarantees that it is
1491 : declared), or it is defined as rpl_ftell (declared above). */
1492 : _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
1493 : "on 32-bit platforms - "
1494 : "use ftello function for handling of large files");
1495 : #endif
1496 :
1497 :
1498 : #if 1
1499 : # if 0 && (0 || 0)
1500 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1501 : # undef fwrite
1502 : # define fwrite rpl_fwrite
1503 : # endif
1504 : _GL_FUNCDECL_RPL (fwrite, size_t,
1505 : (const void *restrict ptr, size_t s, size_t n,
1506 : FILE *restrict stream),
1507 : _GL_ARG_NONNULL ((1, 4)));
1508 : _GL_CXXALIAS_RPL (fwrite, size_t,
1509 : (const void *restrict ptr, size_t s, size_t n,
1510 : FILE *restrict stream));
1511 : # else
1512 : _GL_CXXALIAS_SYS (fwrite, size_t,
1513 : (const void *restrict ptr, size_t s, size_t n,
1514 : FILE *restrict stream));
1515 :
1516 : /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
1517 : <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
1518 : which sometimes causes an unwanted diagnostic for fwrite calls.
1519 : This affects only function declaration attributes under certain
1520 : versions of gcc and clang, and is not needed for C++. */
1521 : # if (0 < __USE_FORTIFY_LEVEL \
1522 : && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
1523 : && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \
1524 : && !defined __cplusplus)
1525 : # undef fwrite
1526 : # undef fwrite_unlocked
1527 : _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite,
1528 : (const void *__restrict, size_t, size_t,
1529 : FILE *__restrict),
1530 : fwrite);
1531 : _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked,
1532 : (const void *__restrict, size_t, size_t,
1533 : FILE *__restrict),
1534 : fwrite_unlocked);
1535 : # define fwrite rpl_fwrite
1536 : # define fwrite_unlocked rpl_fwrite_unlocked
1537 : # endif
1538 : # endif
1539 : # if __GLIBC__ >= 2
1540 : _GL_CXXALIASWARN (fwrite);
1541 : # endif
1542 : #elif (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
1543 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1544 : # undef fwrite
1545 : # define fwrite gl_consolesafe_fwrite
1546 : # endif
1547 : #endif
1548 :
1549 : #if 1
1550 : # if 0 && 0
1551 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1552 : # undef getc
1553 : # define getc rpl_fgetc
1554 : # endif
1555 : _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
1556 : _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
1557 : # else
1558 : _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
1559 : # endif
1560 : # if __GLIBC__ >= 2
1561 : _GL_CXXALIASWARN (getc);
1562 : # endif
1563 : #endif
1564 :
1565 : #if 1
1566 : # if 0 && 0
1567 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1568 : # undef getchar
1569 : # define getchar rpl_getchar
1570 : # endif
1571 : _GL_FUNCDECL_RPL (getchar, int, (void), );
1572 : _GL_CXXALIAS_RPL (getchar, int, (void));
1573 : # else
1574 : _GL_CXXALIAS_SYS (getchar, int, (void));
1575 : # endif
1576 : # if __GLIBC__ >= 2
1577 : _GL_CXXALIASWARN (getchar);
1578 : # endif
1579 : #endif
1580 :
1581 : #if 0
1582 : /* Read input, up to (and including) the next occurrence of DELIMITER, from
1583 : STREAM, store it in *LINEPTR (and NUL-terminate it).
1584 : *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
1585 : bytes of space. It is realloc'd as necessary.
1586 : Return the number of bytes read and stored at *LINEPTR (not including the
1587 : NUL terminator), or -1 on error or EOF. */
1588 : # if 0
1589 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1590 : # undef getdelim
1591 : # define getdelim rpl_getdelim
1592 : # endif
1593 : _GL_FUNCDECL_RPL (getdelim, ssize_t,
1594 : (char **restrict lineptr, size_t *restrict linesize,
1595 : int delimiter,
1596 : FILE *restrict stream),
1597 : _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
1598 : _GL_CXXALIAS_RPL (getdelim, ssize_t,
1599 : (char **restrict lineptr, size_t *restrict linesize,
1600 : int delimiter,
1601 : FILE *restrict stream));
1602 : # else
1603 : # if !1
1604 : _GL_FUNCDECL_SYS (getdelim, ssize_t,
1605 : (char **restrict lineptr, size_t *restrict linesize,
1606 : int delimiter,
1607 : FILE *restrict stream),
1608 : _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
1609 : # endif
1610 : _GL_CXXALIAS_SYS (getdelim, ssize_t,
1611 : (char **restrict lineptr, size_t *restrict linesize,
1612 : int delimiter,
1613 : FILE *restrict stream));
1614 : # endif
1615 : # if __GLIBC__ >= 2
1616 : _GL_CXXALIASWARN (getdelim);
1617 : # endif
1618 : #elif defined GNULIB_POSIXCHECK
1619 : # undef getdelim
1620 : # if HAVE_RAW_DECL_GETDELIM
1621 : _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
1622 : "use gnulib module getdelim for portability");
1623 : # endif
1624 : #endif
1625 :
1626 : #if 0
1627 : /* Read a line, up to (and including) the next newline, from STREAM, store it
1628 : in *LINEPTR (and NUL-terminate it).
1629 : *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
1630 : bytes of space. It is realloc'd as necessary.
1631 : Return the number of bytes read and stored at *LINEPTR (not including the
1632 : NUL terminator), or -1 on error or EOF. */
1633 : # if 0
1634 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1635 : # undef getline
1636 : # define getline rpl_getline
1637 : # endif
1638 : _GL_FUNCDECL_RPL (getline, ssize_t,
1639 : (char **restrict lineptr, size_t *restrict linesize,
1640 : FILE *restrict stream),
1641 : _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
1642 : _GL_CXXALIAS_RPL (getline, ssize_t,
1643 : (char **restrict lineptr, size_t *restrict linesize,
1644 : FILE *restrict stream));
1645 : # else
1646 : # if !1
1647 : _GL_FUNCDECL_SYS (getline, ssize_t,
1648 : (char **restrict lineptr, size_t *restrict linesize,
1649 : FILE *restrict stream),
1650 : _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
1651 : # endif
1652 : _GL_CXXALIAS_SYS (getline, ssize_t,
1653 : (char **restrict lineptr, size_t *restrict linesize,
1654 : FILE *restrict stream));
1655 : # endif
1656 : # if __GLIBC__ >= 2 && 1
1657 : _GL_CXXALIASWARN (getline);
1658 : # endif
1659 : #elif defined GNULIB_POSIXCHECK
1660 : # undef getline
1661 : # if HAVE_RAW_DECL_GETLINE
1662 : _GL_WARN_ON_USE (getline, "getline is unportable - "
1663 : "use gnulib module getline for portability");
1664 : # endif
1665 : #endif
1666 :
1667 : /* It is very rare that the developer ever has full control of stdin,
1668 : so any use of gets warrants an unconditional warning; besides, C11
1669 : removed it. */
1670 : #undef gets
1671 : #if HAVE_RAW_DECL_GETS && !defined __cplusplus
1672 : _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
1673 : #endif
1674 :
1675 : #if 1
1676 : /* On native Windows, map 'getw' to '_getw', so that -loldnames is not
1677 : required. In C++ with GNULIB_NAMESPACE, avoid differences between
1678 : platforms by defining GNULIB_NAMESPACE::getw always. */
1679 : # if defined _WIN32 && !defined __CYGWIN__
1680 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1681 : # undef getw
1682 : # define getw _getw
1683 : # endif
1684 : _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
1685 : # else
1686 : # if 1
1687 : # if defined __APPLE__ && defined __MACH__
1688 : /* The presence of the declaration depends on _POSIX_C_SOURCE. */
1689 : _GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream), );
1690 : # endif
1691 : _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
1692 : # endif
1693 : # endif
1694 : # if __GLIBC__ >= 2
1695 : _GL_CXXALIASWARN (getw);
1696 : # endif
1697 : #endif
1698 :
1699 : #if 0
1700 : struct obstack;
1701 : /* Grows an obstack with formatted output. Returns the number of
1702 : bytes added to OBS. No trailing nul byte is added, and the
1703 : object should be closed with obstack_finish before use.
1704 : Upon memory allocation error, calls obstack_alloc_failed_handler.
1705 : Upon other error, returns -1 with errno set.
1706 :
1707 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1708 : Therefore, if the format string is valid and does not use %ls/%lc
1709 : directives nor widths, the only possible failure code is through
1710 : obstack_alloc_failed_handler. */
1711 : _GL_FUNCDECL_SYS (obstack_zprintf, ptrdiff_t,
1712 : (struct obstack *obs, const char *format, ...),
1713 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1714 : _GL_ARG_NONNULL ((1, 2)));
1715 : _GL_CXXALIAS_SYS (obstack_zprintf, ptrdiff_t,
1716 : (struct obstack *obs, const char *format, ...));
1717 : _GL_FUNCDECL_SYS (obstack_vzprintf, ptrdiff_t,
1718 : (struct obstack *obs, const char *format, va_list args),
1719 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1720 : _GL_ARG_NONNULL ((1, 2)));
1721 : _GL_CXXALIAS_SYS (obstack_vzprintf, ptrdiff_t,
1722 : (struct obstack *obs, const char *format, va_list args));
1723 : #endif
1724 :
1725 : #if 0 || 0
1726 : struct obstack;
1727 : /* Grows an obstack with formatted output. Returns the number of
1728 : bytes added to OBS. No trailing nul byte is added, and the
1729 : object should be closed with obstack_finish before use.
1730 : Upon memory allocation error, calls obstack_alloc_failed_handler.
1731 : Upon other error, returns -1. */
1732 : # if 0
1733 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1734 : # define obstack_printf rpl_obstack_printf
1735 : # endif
1736 : _GL_FUNCDECL_RPL (obstack_printf, int,
1737 : (struct obstack *obs, const char *format, ...),
1738 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1739 : _GL_ARG_NONNULL ((1, 2)));
1740 : _GL_CXXALIAS_RPL (obstack_printf, int,
1741 : (struct obstack *obs, const char *format, ...));
1742 : # else
1743 : # if !1
1744 : _GL_FUNCDECL_SYS (obstack_printf, int,
1745 : (struct obstack *obs, const char *format, ...),
1746 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1747 : _GL_ARG_NONNULL ((1, 2)));
1748 : # endif
1749 : _GL_CXXALIAS_SYS (obstack_printf, int,
1750 : (struct obstack *obs, const char *format, ...));
1751 : # endif
1752 : _GL_CXXALIASWARN (obstack_printf);
1753 : # if 0
1754 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1755 : # define obstack_vprintf rpl_obstack_vprintf
1756 : # endif
1757 : _GL_FUNCDECL_RPL (obstack_vprintf, int,
1758 : (struct obstack *obs, const char *format, va_list args),
1759 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1760 : _GL_ARG_NONNULL ((1, 2)));
1761 : _GL_CXXALIAS_RPL (obstack_vprintf, int,
1762 : (struct obstack *obs, const char *format, va_list args));
1763 : # else
1764 : # if !1
1765 : _GL_FUNCDECL_SYS (obstack_vprintf, int,
1766 : (struct obstack *obs, const char *format, va_list args),
1767 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1768 : _GL_ARG_NONNULL ((1, 2)));
1769 : # endif
1770 : _GL_CXXALIAS_SYS (obstack_vprintf, int,
1771 : (struct obstack *obs, const char *format, va_list args));
1772 : # endif
1773 : _GL_CXXALIASWARN (obstack_vprintf);
1774 : #endif
1775 :
1776 : #if 0
1777 : # if !1
1778 : _GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
1779 : # endif
1780 : _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
1781 : _GL_CXXALIASWARN (pclose);
1782 : #elif defined GNULIB_POSIXCHECK
1783 : # undef pclose
1784 : # if HAVE_RAW_DECL_PCLOSE
1785 : _GL_WARN_ON_USE (pclose, "pclose is unportable - "
1786 : "use gnulib module pclose for more portability");
1787 : # endif
1788 : #endif
1789 :
1790 : #if 0
1791 : /* Print a message to standard error, describing the value of ERRNO,
1792 : (if STRING is not NULL and not empty) prefixed with STRING and ": ",
1793 : and terminated with a newline. */
1794 : # if 0
1795 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1796 : # define perror rpl_perror
1797 : # endif
1798 : _GL_FUNCDECL_RPL (perror, void, (const char *string), );
1799 : _GL_CXXALIAS_RPL (perror, void, (const char *string));
1800 : # else
1801 : _GL_CXXALIAS_SYS (perror, void, (const char *string));
1802 : # endif
1803 : # if __GLIBC__ >= 2
1804 : _GL_CXXALIASWARN (perror);
1805 : # endif
1806 : #elif defined GNULIB_POSIXCHECK
1807 : # undef perror
1808 : /* Assume perror is always declared. */
1809 : _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1810 : "use gnulib module perror for portability");
1811 : #endif
1812 :
1813 : #if 0
1814 : # if 0
1815 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1816 : # undef popen
1817 : # define popen rpl_popen
1818 : # endif
1819 : _GL_FUNCDECL_RPL (popen, FILE *,
1820 : (const char *cmd, const char *mode),
1821 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1822 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1823 : _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
1824 : # else
1825 : # if !1 || (__GNUC__ >= 11 && !defined __clang__)
1826 : _GL_FUNCDECL_SYS (popen, FILE *,
1827 : (const char *cmd, const char *mode),
1828 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1829 : _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1830 : # endif
1831 : _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
1832 : # endif
1833 : _GL_CXXALIASWARN (popen);
1834 : #else
1835 : # if 0 \
1836 : && (__GNUC__ >= 11 && !defined __clang__) && !defined popen
1837 : /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1838 : _GL_FUNCDECL_SYS (popen, FILE *,
1839 : (const char *cmd, const char *mode),
1840 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1841 : _GL_ATTRIBUTE_MALLOC);
1842 : # endif
1843 : # if defined GNULIB_POSIXCHECK
1844 : # undef popen
1845 : # if HAVE_RAW_DECL_POPEN
1846 : _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1847 : "use gnulib module popen or pipe for more portability");
1848 : # endif
1849 : # endif
1850 : #endif
1851 :
1852 : #if 0
1853 : /* Prints formatted output to standard output.
1854 : Returns the number of bytes written to standard output. Upon failure,
1855 : returns -1 with stdout's error indicator set.
1856 : Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1857 : Therefore, if the format string is valid and does not use %ls/%lc
1858 : directives nor widths, the only possible failure causes are ENOMEM
1859 : and the possible failure causes from fwrite(). */
1860 : _GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...),
1861 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1862 : _GL_ARG_NONNULL ((1)));
1863 : _GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...));
1864 : #endif
1865 :
1866 : #if 0 || 1
1867 : /* Prints formatted output to standard output.
1868 : Returns the number of bytes written to standard output. Upon failure,
1869 : returns a negative value with stdout's error indicator set. */
1870 : # if (0 && 0) \
1871 : || (1 && 0 && (0 || 0))
1872 : # if defined __GNUC__ || defined __clang__
1873 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1874 : /* Don't break __attribute__((format(printf,M,N))). */
1875 : # define printf __printf__
1876 : # endif
1877 : # if 0 || 0
1878 : _GL_FUNCDECL_RPL_1 (__printf__, int,
1879 : (const char *restrict format, ...)
1880 : __asm__ (
1881 : _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
1882 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1883 : _GL_ARG_NONNULL ((1)));
1884 : # else
1885 : _GL_FUNCDECL_RPL_1 (__printf__, int,
1886 : (const char *restrict format, ...)
1887 : __asm__ (
1888 : _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
1889 : _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
1890 : _GL_ARG_NONNULL ((1)));
1891 : # endif
1892 : _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
1893 : # else
1894 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1895 : # define printf rpl_printf
1896 : # endif
1897 : _GL_FUNCDECL_RPL (printf, int,
1898 : (const char *restrict format, ...),
1899 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1900 : _GL_ARG_NONNULL ((1)));
1901 : _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
1902 : # endif
1903 : # define GNULIB_overrides_printf 1
1904 : # else
1905 : _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
1906 : # endif
1907 : # if __GLIBC__ >= 2
1908 : _GL_CXXALIASWARN (printf);
1909 : # endif
1910 : #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1911 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1912 : # undef printf
1913 : # define printf gl_consolesafe_printf
1914 : # endif
1915 : #endif
1916 : #if !0 && defined GNULIB_POSIXCHECK
1917 : # if !GNULIB_overrides_printf
1918 : # undef printf
1919 : # endif
1920 : /* Assume printf is always declared. */
1921 : _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1922 : "use gnulib module printf-posix for portable "
1923 : "POSIX compliance");
1924 : #endif
1925 :
1926 : #if 1
1927 : # if 0 && (0 || 0)
1928 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1929 : # undef putc
1930 : # define putc rpl_fputc
1931 : # endif
1932 : _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
1933 : _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
1934 : # else
1935 : _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
1936 : # endif
1937 : # if __GLIBC__ >= 2
1938 : _GL_CXXALIASWARN (putc);
1939 : # endif
1940 : #endif
1941 :
1942 : #if 1
1943 : # if 0 && (0 || 0)
1944 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1945 : # undef putchar
1946 : # define putchar rpl_putchar
1947 : # endif
1948 : _GL_FUNCDECL_RPL (putchar, int, (int c), );
1949 : _GL_CXXALIAS_RPL (putchar, int, (int c));
1950 : # else
1951 : _GL_CXXALIAS_SYS (putchar, int, (int c));
1952 : # endif
1953 : # if __GLIBC__ >= 2
1954 : _GL_CXXALIASWARN (putchar);
1955 : # endif
1956 : #endif
1957 :
1958 : #if 1
1959 : # if 0 && (0 || 0)
1960 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1961 : # undef puts
1962 : # define puts rpl_puts
1963 : # endif
1964 : _GL_FUNCDECL_RPL (puts, int, (const char *string), _GL_ARG_NONNULL ((1)));
1965 : _GL_CXXALIAS_RPL (puts, int, (const char *string));
1966 : # else
1967 : _GL_CXXALIAS_SYS (puts, int, (const char *string));
1968 : # endif
1969 : # if __GLIBC__ >= 2
1970 : _GL_CXXALIASWARN (puts);
1971 : # endif
1972 : #endif
1973 :
1974 : #if 1
1975 : /* On native Windows, map 'putw' to '_putw', so that -loldnames is not
1976 : required. In C++ with GNULIB_NAMESPACE, avoid differences between
1977 : platforms by defining GNULIB_NAMESPACE::putw always. */
1978 : # if defined _WIN32 && !defined __CYGWIN__
1979 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1980 : # undef putw
1981 : # define putw _putw
1982 : # endif
1983 : _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1984 : # else
1985 : # if 1
1986 : # if defined __APPLE__ && defined __MACH__
1987 : /* The presence of the declaration depends on _POSIX_C_SOURCE. */
1988 : _GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream), );
1989 : # endif
1990 : _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1991 : # endif
1992 : # endif
1993 : # if __GLIBC__ >= 2
1994 : _GL_CXXALIASWARN (putw);
1995 : # endif
1996 : #endif
1997 :
1998 : #if 0
1999 : # if 0
2000 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2001 : # undef remove
2002 : # define remove rpl_remove
2003 : # endif
2004 : _GL_FUNCDECL_RPL (remove, int, (const char *name), _GL_ARG_NONNULL ((1)));
2005 : _GL_CXXALIAS_RPL (remove, int, (const char *name));
2006 : # else
2007 : _GL_CXXALIAS_SYS (remove, int, (const char *name));
2008 : # endif
2009 : # if __GLIBC__ >= 2
2010 : _GL_CXXALIASWARN (remove);
2011 : # endif
2012 : #elif defined GNULIB_POSIXCHECK
2013 : # undef remove
2014 : /* Assume remove is always declared. */
2015 : _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
2016 : "use gnulib module remove for more portability");
2017 : #endif
2018 :
2019 : #if 0
2020 : # if 0
2021 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2022 : # undef rename
2023 : # define rename rpl_rename
2024 : # endif
2025 : _GL_FUNCDECL_RPL (rename, int,
2026 : (const char *old_filename, const char *new_filename),
2027 : _GL_ARG_NONNULL ((1, 2)));
2028 : _GL_CXXALIAS_RPL (rename, int,
2029 : (const char *old_filename, const char *new_filename));
2030 : # else
2031 : _GL_CXXALIAS_SYS (rename, int,
2032 : (const char *old_filename, const char *new_filename));
2033 : # endif
2034 : # if __GLIBC__ >= 2
2035 : _GL_CXXALIASWARN (rename);
2036 : # endif
2037 : #elif defined GNULIB_POSIXCHECK
2038 : # undef rename
2039 : /* Assume rename is always declared. */
2040 : _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
2041 : "use gnulib module rename for more portability");
2042 : #endif
2043 :
2044 : #if 0
2045 : # if 0
2046 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2047 : # undef renameat
2048 : # define renameat rpl_renameat
2049 : # endif
2050 : _GL_FUNCDECL_RPL (renameat, int,
2051 : (int fd1, char const *file1, int fd2, char const *file2),
2052 : _GL_ARG_NONNULL ((2, 4)));
2053 : _GL_CXXALIAS_RPL (renameat, int,
2054 : (int fd1, char const *file1, int fd2, char const *file2));
2055 : # else
2056 : # if !1
2057 : _GL_FUNCDECL_SYS (renameat, int,
2058 : (int fd1, char const *file1, int fd2, char const *file2),
2059 : _GL_ARG_NONNULL ((2, 4)));
2060 : # endif
2061 : _GL_CXXALIAS_SYS (renameat, int,
2062 : (int fd1, char const *file1, int fd2, char const *file2));
2063 : # endif
2064 : _GL_CXXALIASWARN (renameat);
2065 : #elif defined GNULIB_POSIXCHECK
2066 : # undef renameat
2067 : # if HAVE_RAW_DECL_RENAMEAT
2068 : _GL_WARN_ON_USE (renameat, "renameat is not portable - "
2069 : "use gnulib module renameat for portability");
2070 : # endif
2071 : #endif
2072 :
2073 : #if 1
2074 : # if 0 && 0
2075 : # if defined __GNUC__ || defined __clang__
2076 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2077 : # undef scanf
2078 : /* Don't break __attribute__((format(scanf,M,N))). */
2079 : # define scanf __scanf__
2080 : # endif
2081 : _GL_FUNCDECL_RPL_1 (__scanf__, int,
2082 : (const char *restrict format, ...)
2083 : __asm__ (
2084 : _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)),
2085 : _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
2086 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2087 : _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
2088 : # else
2089 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2090 : # undef scanf
2091 : # define scanf rpl_scanf
2092 : # endif
2093 : _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...),
2094 : _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
2095 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2096 : _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
2097 : # endif
2098 : # else
2099 : _GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
2100 : # endif
2101 : # if __GLIBC__ >= 2
2102 : _GL_CXXALIASWARN (scanf);
2103 : # endif
2104 : #endif
2105 :
2106 : #if 0
2107 : /* Prints formatted output to string STR. Similar to sprintf, but the
2108 : additional parameter SIZE limits how much is written into STR.
2109 : STR may be NULL, in which case nothing will be written.
2110 : Returns the string length of the formatted string (which may be larger
2111 : than SIZE). Upon failure, returns -1 with errno set.
2112 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2113 : Therefore, if the format string is valid and does not use %ls/%lc
2114 : directives nor widths, the only possible failure code is ENOMEM. */
2115 : _GL_FUNCDECL_SYS (snzprintf, ptrdiff_t,
2116 : (char *restrict str, size_t size,
2117 : const char *restrict format, ...),
2118 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
2119 : _GL_ARG_NONNULL ((3)));
2120 : _GL_CXXALIAS_SYS (snzprintf, ptrdiff_t,
2121 : (char *restrict str, size_t size,
2122 : const char *restrict format, ...));
2123 : #endif
2124 :
2125 : #if 1
2126 : /* Prints formatted output to string STR. Similar to sprintf, but the
2127 : additional parameter SIZE limits how much is written into STR.
2128 : STR may be NULL, in which case nothing will be written.
2129 : Returns the string length of the formatted string (which may be larger
2130 : than SIZE). Upon failure, returns a negative value. */
2131 : # if 0
2132 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2133 : # define snprintf rpl_snprintf
2134 : # endif
2135 : # define GNULIB_overrides_snprintf 1
2136 : _GL_FUNCDECL_RPL (snprintf, int,
2137 : (char *restrict str, size_t size,
2138 : const char *restrict format, ...),
2139 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
2140 : _GL_ARG_NONNULL ((3)));
2141 : _GL_CXXALIAS_RPL (snprintf, int,
2142 : (char *restrict str, size_t size,
2143 : const char *restrict format, ...));
2144 : # else
2145 : # if !1
2146 : _GL_FUNCDECL_SYS (snprintf, int,
2147 : (char *restrict str, size_t size,
2148 : const char *restrict format, ...),
2149 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
2150 : _GL_ARG_NONNULL ((3)));
2151 : # endif
2152 : _GL_CXXALIAS_SYS (snprintf, int,
2153 : (char *restrict str, size_t size,
2154 : const char *restrict format, ...));
2155 : # endif
2156 : # if __GLIBC__ >= 2
2157 : _GL_CXXALIASWARN (snprintf);
2158 : # endif
2159 : #elif defined GNULIB_POSIXCHECK
2160 : # undef snprintf
2161 : # if HAVE_RAW_DECL_SNPRINTF
2162 : _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
2163 : "use gnulib module snprintf for portability");
2164 : # endif
2165 : #endif
2166 :
2167 : #if 0
2168 : /* Prints formatted output to string STR.
2169 : Returns the string length of the formatted string. Upon failure,
2170 : returns -1 with errno set.
2171 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2172 : Therefore, if the format string is valid and does not use %ls/%lc
2173 : directives nor widths, the only possible failure code is ENOMEM. */
2174 : _GL_FUNCDECL_SYS (szprintf, ptrdiff_t,
2175 : (char *restrict str,
2176 : const char *restrict format, ...),
2177 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
2178 : _GL_ARG_NONNULL ((1, 2)));
2179 : _GL_CXXALIAS_SYS (szprintf, ptrdiff_t,
2180 : (char *restrict str,
2181 : const char *restrict format, ...));
2182 : #endif
2183 :
2184 : /* Some people would argue that all sprintf uses should be warned about
2185 : (for example, OpenBSD issues a link warning for it),
2186 : since it can cause security holes due to buffer overruns.
2187 : However, we believe that sprintf can be used safely, and is more
2188 : efficient than snprintf in those safe cases; and as proof of our
2189 : belief, we use sprintf in several gnulib modules. So this header
2190 : intentionally avoids adding a warning to sprintf except when
2191 : GNULIB_POSIXCHECK is defined. */
2192 :
2193 : #if 0
2194 : /* Prints formatted output to string STR.
2195 : Returns the string length of the formatted string. Upon failure,
2196 : returns a negative value. */
2197 : # if 0
2198 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2199 : # define sprintf rpl_sprintf
2200 : # endif
2201 : # define GNULIB_overrides_sprintf 1
2202 : _GL_FUNCDECL_RPL (sprintf, int,
2203 : (char *restrict str, const char *restrict format, ...),
2204 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
2205 : _GL_ARG_NONNULL ((1, 2)));
2206 : _GL_CXXALIAS_RPL (sprintf, int,
2207 : (char *restrict str, const char *restrict format, ...));
2208 : # else
2209 : _GL_CXXALIAS_SYS (sprintf, int,
2210 : (char *restrict str, const char *restrict format, ...));
2211 : # endif
2212 : # if __GLIBC__ >= 2
2213 : _GL_CXXALIASWARN (sprintf);
2214 : # endif
2215 : #elif defined GNULIB_POSIXCHECK
2216 : # undef sprintf
2217 : /* Assume sprintf is always declared. */
2218 : _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
2219 : "use gnulib module sprintf-posix for portable "
2220 : "POSIX compliance");
2221 : #endif
2222 :
2223 : #if 1
2224 : /* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
2225 : required. In C++ with GNULIB_NAMESPACE, avoid differences between
2226 : platforms by defining GNULIB_NAMESPACE::tempnam always. */
2227 : # if defined _WIN32 && !defined __CYGWIN__
2228 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2229 : # undef tempnam
2230 : # define tempnam _tempnam
2231 : # endif
2232 : _GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix));
2233 : # else
2234 : _GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix));
2235 : # endif
2236 : _GL_CXXALIASWARN (tempnam);
2237 : #endif
2238 :
2239 : #if 0
2240 : # if 0
2241 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2242 : # define tmpfile rpl_tmpfile
2243 : # endif
2244 : _GL_FUNCDECL_RPL (tmpfile, FILE *, (void),
2245 : _GL_ATTRIBUTE_DEALLOC (fclose, 1)
2246 : _GL_ATTRIBUTE_MALLOC
2247 : _GL_ATTRIBUTE_NODISCARD);
2248 : _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
2249 : # else
2250 : # if __GNUC__ >= 11 && !defined __clang__
2251 : /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
2252 : _GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
2253 : _GL_ATTRIBUTE_DEALLOC (fclose, 1)
2254 : _GL_ATTRIBUTE_MALLOC
2255 : _GL_ATTRIBUTE_NODISCARD);
2256 : # endif
2257 : _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
2258 : # endif
2259 : # if __GLIBC__ >= 2
2260 : _GL_CXXALIASWARN (tmpfile);
2261 : # endif
2262 : #else
2263 : # if 0 \
2264 : && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile
2265 : /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
2266 : _GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
2267 : _GL_ATTRIBUTE_DEALLOC (fclose, 1)
2268 : _GL_ATTRIBUTE_MALLOC);
2269 : # endif
2270 : # if defined GNULIB_POSIXCHECK
2271 : # undef tmpfile
2272 : # if HAVE_RAW_DECL_TMPFILE
2273 : _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
2274 : "use gnulib module tmpfile for portability");
2275 : # endif
2276 : # endif
2277 : #endif
2278 :
2279 : #if 0
2280 : /* Prints formatted output to a string dynamically allocated with malloc().
2281 : If the memory allocation succeeds, it stores the address of the string in
2282 : *RESULT and returns the number of resulting bytes, excluding the trailing
2283 : NUL. Upon memory allocation error, or some other error, it returns -1
2284 : with errno set.
2285 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2286 : Therefore, if the format string is valid and does not use %ls/%lc
2287 : directives nor widths, the only possible failure code is ENOMEM. */
2288 : _GL_FUNCDECL_SYS (aszprintf, ptrdiff_t,
2289 : (char **result, const char *format, ...),
2290 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
2291 : _GL_ARG_NONNULL ((1, 2))
2292 : _GL_ATTRIBUTE_NODISCARD);
2293 : _GL_CXXALIAS_SYS (aszprintf, ptrdiff_t,
2294 : (char **result, const char *format, ...));
2295 : _GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t,
2296 : (char **result, const char *format, va_list args),
2297 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2298 : _GL_ARG_NONNULL ((1, 2))
2299 : _GL_ATTRIBUTE_NODISCARD);
2300 : _GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t,
2301 : (char **result, const char *format, va_list args));
2302 : #endif
2303 :
2304 : #if 0
2305 : /* Write formatted output to a string dynamically allocated with malloc().
2306 : If the memory allocation succeeds, store the address of the string in
2307 : *RESULT and return the number of resulting bytes, excluding the trailing
2308 : NUL. Upon memory allocation error, or some other error, return -1. */
2309 : # if 0
2310 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2311 : # define asprintf rpl_asprintf
2312 : # endif
2313 : # define GNULIB_overrides_asprintf
2314 : _GL_FUNCDECL_RPL (asprintf, int,
2315 : (char **result, const char *format, ...),
2316 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
2317 : _GL_ARG_NONNULL ((1, 2))
2318 : _GL_ATTRIBUTE_NODISCARD);
2319 : _GL_CXXALIAS_RPL (asprintf, int,
2320 : (char **result, const char *format, ...));
2321 : # else
2322 : # if !1
2323 : _GL_FUNCDECL_SYS (asprintf, int,
2324 : (char **result, const char *format, ...),
2325 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
2326 : _GL_ARG_NONNULL ((1, 2))
2327 : _GL_ATTRIBUTE_NODISCARD);
2328 : # endif
2329 : _GL_CXXALIAS_SYS (asprintf, int,
2330 : (char **result, const char *format, ...));
2331 : # endif
2332 : _GL_CXXALIASWARN (asprintf);
2333 : # if 0
2334 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2335 : # define vasprintf rpl_vasprintf
2336 : # endif
2337 : # define GNULIB_overrides_vasprintf 1
2338 : _GL_FUNCDECL_RPL (vasprintf, int,
2339 : (char **result, const char *format, va_list args),
2340 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2341 : _GL_ARG_NONNULL ((1, 2))
2342 : _GL_ATTRIBUTE_NODISCARD);
2343 : _GL_CXXALIAS_RPL (vasprintf, int,
2344 : (char **result, const char *format, va_list args));
2345 : # else
2346 : # if !1
2347 : _GL_FUNCDECL_SYS (vasprintf, int,
2348 : (char **result, const char *format, va_list args),
2349 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2350 : _GL_ARG_NONNULL ((1, 2))
2351 : _GL_ATTRIBUTE_NODISCARD);
2352 : # endif
2353 : _GL_CXXALIAS_SYS (vasprintf, int,
2354 : (char **result, const char *format, va_list args));
2355 : # endif
2356 : _GL_CXXALIASWARN (vasprintf);
2357 : #endif
2358 :
2359 : #if 0
2360 : /* Prints formatted output to file descriptor FD.
2361 : Returns the number of bytes written to the file descriptor. Upon
2362 : failure, returns -1 with errno set.
2363 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2364 : Therefore, if the format string is valid and does not use %ls/%lc
2365 : directives nor widths, the only possible failure codes are ENOMEM
2366 : and the possible failure codes from write(), excluding EINTR. */
2367 : _GL_FUNCDECL_SYS (vdzprintf, off64_t,
2368 : (int fd, const char *restrict format, va_list args),
2369 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2370 : _GL_ARG_NONNULL ((2)));
2371 : _GL_CXXALIAS_SYS (vdzprintf, off64_t,
2372 : (int fd, const char *restrict format, va_list args));
2373 : #endif
2374 :
2375 : #if 0
2376 : /* Prints formatted output to file descriptor FD.
2377 : Returns the number of bytes written to the file descriptor. Upon
2378 : failure, returns a negative value. */
2379 : # if 0
2380 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2381 : # define vdprintf rpl_vdprintf
2382 : # endif
2383 : _GL_FUNCDECL_RPL (vdprintf, int,
2384 : (int fd, const char *restrict format, va_list args),
2385 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2386 : _GL_ARG_NONNULL ((2)));
2387 : _GL_CXXALIAS_RPL (vdprintf, int,
2388 : (int fd, const char *restrict format, va_list args));
2389 : # else
2390 : # if !1
2391 : _GL_FUNCDECL_SYS (vdprintf, int,
2392 : (int fd, const char *restrict format, va_list args),
2393 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2394 : _GL_ARG_NONNULL ((2)));
2395 : # endif
2396 : /* Need to cast, because on Solaris, the third parameter will likely be
2397 : __va_list args. */
2398 : _GL_CXXALIAS_SYS_CAST (vdprintf, int,
2399 : (int fd, const char *restrict format, va_list args));
2400 : # endif
2401 : # if __GLIBC__ >= 2
2402 : _GL_CXXALIASWARN (vdprintf);
2403 : # endif
2404 : #elif defined GNULIB_POSIXCHECK
2405 : # undef vdprintf
2406 : # if HAVE_RAW_DECL_VDPRINTF
2407 : _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
2408 : "use gnulib module vdprintf for portability");
2409 : # endif
2410 : #endif
2411 :
2412 : #if 1
2413 : /* Prints formatted output to stream FP.
2414 : Returns the number of bytes written to the stream. Upon failure,
2415 : returns -1 with the stream's error indicator set.
2416 : Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
2417 : Therefore, if the format string is valid and does not use %ls/%lc
2418 : directives nor widths, the only possible failure causes are ENOMEM
2419 : and the possible failure causes from fwrite(). */
2420 14391 : _GL_FUNCDECL_SYS (vfzprintf, off64_t,
2421 : (FILE *restrict fp,
2422 : const char *restrict format, va_list args),
2423 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2424 : _GL_ARG_NONNULL ((1, 2)));
2425 : _GL_CXXALIAS_SYS (vfzprintf, off64_t,
2426 : (FILE *restrict fp,
2427 : const char *restrict format, va_list args));
2428 : #endif
2429 :
2430 : #if 0 || 1
2431 : /* Prints formatted output to stream FP.
2432 : Returns the number of bytes written to the stream. Upon failure,
2433 : returns a negative value with the stream's error indicator set. */
2434 : # if (0 && 0) \
2435 : || (1 && 0 && (0 || 0))
2436 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2437 : # define vfprintf rpl_vfprintf
2438 : # endif
2439 : # define GNULIB_overrides_vfprintf 1
2440 : # if 0
2441 : _GL_FUNCDECL_RPL (vfprintf, int,
2442 : (FILE *restrict fp,
2443 : const char *restrict format, va_list args),
2444 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2445 : _GL_ARG_NONNULL ((1, 2)));
2446 : # else
2447 : _GL_FUNCDECL_RPL (vfprintf, int,
2448 : (FILE *restrict fp,
2449 : const char *restrict format, va_list args),
2450 : _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
2451 : _GL_ARG_NONNULL ((1, 2)));
2452 : # endif
2453 : _GL_CXXALIAS_RPL (vfprintf, int,
2454 : (FILE *restrict fp,
2455 : const char *restrict format, va_list args));
2456 : # else
2457 : /* Need to cast, because on Solaris, the third parameter is
2458 : __va_list args
2459 : and GCC's fixincludes did not change this to __gnuc_va_list. */
2460 : _GL_CXXALIAS_SYS_CAST (vfprintf, int,
2461 : (FILE *restrict fp,
2462 : const char *restrict format, va_list args));
2463 : # endif
2464 : # if __GLIBC__ >= 2
2465 : _GL_CXXALIASWARN (vfprintf);
2466 : # endif
2467 : #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
2468 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2469 : # undef vfprintf
2470 : # define vfprintf gl_consolesafe_vfprintf
2471 : # endif
2472 : #endif
2473 : #if !0 && defined GNULIB_POSIXCHECK
2474 : # if !GNULIB_overrides_vfprintf
2475 : # undef vfprintf
2476 : # endif
2477 : /* Assume vfprintf is always declared. */
2478 : _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
2479 : "use gnulib module vfprintf-posix for portable "
2480 : "POSIX compliance");
2481 : #endif
2482 :
2483 : #if 0
2484 : # if 0 && 0
2485 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2486 : # undef vfscanf
2487 : # define vfscanf rpl_vfscanf
2488 : # endif
2489 : _GL_FUNCDECL_RPL (vfscanf, int,
2490 : (FILE *restrict stream,
2491 : const char *restrict format, va_list args),
2492 : _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
2493 : _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2494 : _GL_CXXALIAS_RPL (vfscanf, int,
2495 : (FILE *restrict stream,
2496 : const char *restrict format, va_list args));
2497 : # else
2498 : _GL_CXXALIAS_SYS (vfscanf, int,
2499 : (FILE *restrict stream,
2500 : const char *restrict format, va_list args));
2501 : # endif
2502 : # if __GLIBC__ >= 2
2503 : _GL_CXXALIASWARN (vfscanf);
2504 : # endif
2505 : #endif
2506 :
2507 : #if 0
2508 : /* Prints formatted output to standard output.
2509 : Returns the number of bytes written to standard output. Upon failure,
2510 : returns -1 with stdout's error indicator set.
2511 : Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
2512 : Therefore, if the format string is valid and does not use %ls/%lc
2513 : directives nor widths, the only possible failure causes are ENOMEM
2514 : and the possible failure causes from fwrite(). */
2515 : _GL_FUNCDECL_SYS (vzprintf, off64_t,
2516 : (const char *restrict format, va_list args),
2517 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
2518 : _GL_ARG_NONNULL ((1)));
2519 : _GL_CXXALIAS_SYS (vzprintf, off64_t,
2520 : (const char *restrict format, va_list args));
2521 : #endif
2522 :
2523 : #if 0 || 1
2524 : /* Prints formatted output to standard output.
2525 : Returns the number of bytes written to standard output. Upon failure,
2526 : returns a negative value with stdout's error indicator set. */
2527 : # if (0 && 0) \
2528 : || (1 && 0 && (0 || 0))
2529 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2530 : # define vprintf rpl_vprintf
2531 : # endif
2532 : # define GNULIB_overrides_vprintf 1
2533 : # if 0 || 0
2534 : _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
2535 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
2536 : _GL_ARG_NONNULL ((1)));
2537 : # else
2538 : _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
2539 : _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
2540 : _GL_ARG_NONNULL ((1)));
2541 : # endif
2542 : _GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
2543 : # else
2544 : /* Need to cast, because on Solaris, the second parameter is
2545 : __va_list args
2546 : and GCC's fixincludes did not change this to __gnuc_va_list. */
2547 : _GL_CXXALIAS_SYS_CAST (vprintf, int,
2548 : (const char *restrict format, va_list args));
2549 : # endif
2550 : # if __GLIBC__ >= 2
2551 : _GL_CXXALIASWARN (vprintf);
2552 : # endif
2553 : #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
2554 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2555 : # undef vprintf
2556 : # define vprintf gl_consolesafe_vprintf
2557 : # endif
2558 : #endif
2559 : #if !0 && defined GNULIB_POSIXCHECK
2560 : # if !GNULIB_overrides_vprintf
2561 : # undef vprintf
2562 : # endif
2563 : /* Assume vprintf is always declared. */
2564 : _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
2565 : "use gnulib module vprintf-posix for portable "
2566 : "POSIX compliance");
2567 : #endif
2568 :
2569 : #if 0
2570 : # if 0 && 0
2571 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2572 : # undef vscanf
2573 : # define vscanf rpl_vscanf
2574 : # endif
2575 : _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args),
2576 : _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
2577 : _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2578 : _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
2579 : # else
2580 : _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
2581 : # endif
2582 : # if __GLIBC__ >= 2
2583 : _GL_CXXALIASWARN (vscanf);
2584 : # endif
2585 : #endif
2586 :
2587 : #if 1
2588 : /* Prints formatted output to string STR. Similar to sprintf, but the
2589 : additional parameter SIZE limits how much is written into STR.
2590 : STR may be NULL, in which case nothing will be written.
2591 : Returns the string length of the formatted string (which may be larger
2592 : than SIZE). Upon failure, returns -1 with errno set.
2593 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2594 : Therefore, if the format string is valid and does not use %ls/%lc
2595 : directives nor widths, the only possible failure code is ENOMEM. */
2596 : _GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t,
2597 : (char *restrict str, size_t size,
2598 : const char *restrict format, va_list args),
2599 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
2600 : _GL_ARG_NONNULL ((3)));
2601 : _GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t,
2602 : (char *restrict str, size_t size,
2603 : const char *restrict format, va_list args));
2604 : #endif
2605 :
2606 : #if 1
2607 : /* Prints formatted output to string STR. Similar to vsprintf, but the
2608 : additional parameter SIZE limits how much is written into STR.
2609 : STR may be NULL, in which case nothing will be written.
2610 : Returns the string length of the formatted string (which may be larger
2611 : than SIZE). Upon failure, returns a negative value. */
2612 : # if 0
2613 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2614 : # define vsnprintf rpl_vsnprintf
2615 : # endif
2616 : # define GNULIB_overrides_vsnprintf 1
2617 : _GL_FUNCDECL_RPL (vsnprintf, int,
2618 : (char *restrict str, size_t size,
2619 : const char *restrict format, va_list args),
2620 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
2621 : _GL_ARG_NONNULL ((3)));
2622 : _GL_CXXALIAS_RPL (vsnprintf, int,
2623 : (char *restrict str, size_t size,
2624 : const char *restrict format, va_list args));
2625 : # else
2626 : # if !1
2627 : _GL_FUNCDECL_SYS (vsnprintf, int,
2628 : (char *restrict str, size_t size,
2629 : const char *restrict format, va_list args),
2630 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
2631 : _GL_ARG_NONNULL ((3)));
2632 : # endif
2633 : _GL_CXXALIAS_SYS (vsnprintf, int,
2634 : (char *restrict str, size_t size,
2635 : const char *restrict format, va_list args));
2636 : # endif
2637 : # if __GLIBC__ >= 2
2638 : _GL_CXXALIASWARN (vsnprintf);
2639 : # endif
2640 : #elif defined GNULIB_POSIXCHECK
2641 : # undef vsnprintf
2642 : # if HAVE_RAW_DECL_VSNPRINTF
2643 : _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
2644 : "use gnulib module vsnprintf for portability");
2645 : # endif
2646 : #endif
2647 :
2648 : #if 0
2649 : /* Prints formatted output to string STR.
2650 : Returns the string length of the formatted string. Upon failure,
2651 : returns -1 with errno set.
2652 : Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2653 : Therefore, if the format string is valid and does not use %ls/%lc
2654 : directives nor widths, the only possible failure code is ENOMEM. */
2655 : _GL_FUNCDECL_SYS (vszprintf, ptrdiff_t,
2656 : (char *restrict str,
2657 : const char *restrict format, va_list args),
2658 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2659 : _GL_ARG_NONNULL ((1, 2)));
2660 : _GL_CXXALIAS_SYS (vszprintf, ptrdiff_t,
2661 : (char *restrict str,
2662 : const char *restrict format, va_list args));
2663 : #endif
2664 :
2665 : #if 0
2666 : /* Prints formatted output to string STR.
2667 : Returns the string length of the formatted string. Upon failure,
2668 : returns a negative value. */
2669 : # if 0
2670 : # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2671 : # define vsprintf rpl_vsprintf
2672 : # endif
2673 : # define GNULIB_overrides_vsprintf 1
2674 : _GL_FUNCDECL_RPL (vsprintf, int,
2675 : (char *restrict str,
2676 : const char *restrict format, va_list args),
2677 : _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2678 : _GL_ARG_NONNULL ((1, 2)));
2679 : _GL_CXXALIAS_RPL (vsprintf, int,
2680 : (char *restrict str,
2681 : const char *restrict format, va_list args));
2682 : # else
2683 : /* Need to cast, because on Solaris, the third parameter is
2684 : __va_list args
2685 : and GCC's fixincludes did not change this to __gnuc_va_list. */
2686 : _GL_CXXALIAS_SYS_CAST (vsprintf, int,
2687 : (char *restrict str,
2688 : const char *restrict format, va_list args));
2689 : # endif
2690 : # if __GLIBC__ >= 2
2691 : _GL_CXXALIASWARN (vsprintf);
2692 : # endif
2693 : #elif defined GNULIB_POSIXCHECK
2694 : # undef vsprintf
2695 : /* Assume vsprintf is always declared. */
2696 : _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
2697 : "use gnulib module vsprintf-posix for portable "
2698 : "POSIX compliance");
2699 : #endif
2700 :
2701 : #endif /* _GL_STDIO_H */
2702 : #endif /* _GL_STDIO_H */
2703 : #endif
|