1*fd82c4c4Schristos /* This file is automatically generated.  DO NOT EDIT! */
2*fd82c4c4Schristos /* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp  */
3*fd82c4c4Schristos /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4*fd82c4c4Schristos 
5*fd82c4c4Schristos /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6*fd82c4c4Schristos /* A GNU-like <stdio.h>.
7*fd82c4c4Schristos 
8*fd82c4c4Schristos    Copyright (C) 2004, 2007-2020 Free Software Foundation, Inc.
9*fd82c4c4Schristos 
10*fd82c4c4Schristos    This program is free software; you can redistribute it and/or modify
11*fd82c4c4Schristos    it under the terms of the GNU General Public License as published by
12*fd82c4c4Schristos    the Free Software Foundation; either version 3, or (at your option)
13*fd82c4c4Schristos    any later version.
14*fd82c4c4Schristos 
15*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
16*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*fd82c4c4Schristos    GNU General Public License for more details.
19*fd82c4c4Schristos 
20*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
21*fd82c4c4Schristos    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
22*fd82c4c4Schristos 
23*fd82c4c4Schristos #if __GNUC__ >= 3
24*fd82c4c4Schristos #pragma GCC system_header
25*fd82c4c4Schristos #endif
26*fd82c4c4Schristos 
27*fd82c4c4Schristos 
28*fd82c4c4Schristos #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
29*fd82c4c4Schristos /* Special invocation convention:
30*fd82c4c4Schristos    - Inside glibc header files.
31*fd82c4c4Schristos    - On OSF/1 5.1 we have a sequence of nested includes
32*fd82c4c4Schristos      <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
33*fd82c4c4Schristos      <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
34*fd82c4c4Schristos      In this situation, the functions are not yet declared, therefore we cannot
35*fd82c4c4Schristos      provide the C++ aliases.  */
36*fd82c4c4Schristos 
37*fd82c4c4Schristos #include_next <stdio.h>
38*fd82c4c4Schristos 
39*fd82c4c4Schristos #else
40*fd82c4c4Schristos /* Normal invocation convention.  */
41*fd82c4c4Schristos 
42*fd82c4c4Schristos #ifndef _GL_STDIO_H
43*fd82c4c4Schristos 
44*fd82c4c4Schristos #define _GL_ALREADY_INCLUDING_STDIO_H
45*fd82c4c4Schristos 
46*fd82c4c4Schristos /* The include_next requires a split double-inclusion guard.  */
47*fd82c4c4Schristos #include_next <stdio.h>
48*fd82c4c4Schristos 
49*fd82c4c4Schristos #undef _GL_ALREADY_INCLUDING_STDIO_H
50*fd82c4c4Schristos 
51*fd82c4c4Schristos #ifndef _GL_STDIO_H
52*fd82c4c4Schristos #define _GL_STDIO_H
53*fd82c4c4Schristos 
54*fd82c4c4Schristos /* Get va_list.  Needed on many systems, including glibc 2.8.  */
55*fd82c4c4Schristos #include <stdarg.h>
56*fd82c4c4Schristos 
57*fd82c4c4Schristos #include <stddef.h>
58*fd82c4c4Schristos 
59*fd82c4c4Schristos /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8
60*fd82c4c4Schristos    and eglibc 2.11.2.
61*fd82c4c4Schristos    May also define off_t to a 64-bit type on native Windows.  */
62*fd82c4c4Schristos #include <sys/types.h>
63*fd82c4c4Schristos 
64*fd82c4c4Schristos /* The __attribute__ feature is available in gcc versions 2.5 and later.
65*fd82c4c4Schristos    The __-protected variants of the attributes 'format' and 'printf' are
66*fd82c4c4Schristos    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
67*fd82c4c4Schristos    We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
68*fd82c4c4Schristos    gnulib and libintl do '#define printf __printf__' when they override
69*fd82c4c4Schristos    the 'printf' function.  */
70*fd82c4c4Schristos #ifndef _GL_ATTRIBUTE_FORMAT
71*fd82c4c4Schristos # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
72*fd82c4c4Schristos #  define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
73*fd82c4c4Schristos # else
74*fd82c4c4Schristos #  define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
75*fd82c4c4Schristos # endif
76*fd82c4c4Schristos #endif
77*fd82c4c4Schristos 
78*fd82c4c4Schristos /* _GL_ATTRIBUTE_FORMAT_PRINTF
79*fd82c4c4Schristos    indicates to GCC that the function takes a format string and arguments,
80*fd82c4c4Schristos    where the format string directives are the ones standardized by ISO C99
81*fd82c4c4Schristos    and POSIX.  */
82*fd82c4c4Schristos #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
83*fd82c4c4Schristos # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
84*fd82c4c4Schristos    _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
85*fd82c4c4Schristos #else
86*fd82c4c4Schristos # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
87*fd82c4c4Schristos    _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
88*fd82c4c4Schristos #endif
89*fd82c4c4Schristos 
90*fd82c4c4Schristos /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
91*fd82c4c4Schristos    except that it indicates to GCC that the supported format string directives
92*fd82c4c4Schristos    are the ones of the system printf(), rather than the ones standardized by
93*fd82c4c4Schristos    ISO C99 and POSIX.  */
94*fd82c4c4Schristos #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
95*fd82c4c4Schristos # define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
96*fd82c4c4Schristos   _GL_ATTRIBUTE_FORMAT_PRINTF (formatstring_parameter, first_argument)
97*fd82c4c4Schristos #else
98*fd82c4c4Schristos # define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
99*fd82c4c4Schristos   _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
100*fd82c4c4Schristos #endif
101*fd82c4c4Schristos 
102*fd82c4c4Schristos /* _GL_ATTRIBUTE_FORMAT_SCANF
103*fd82c4c4Schristos    indicates to GCC that the function takes a format string and arguments,
104*fd82c4c4Schristos    where the format string directives are the ones standardized by ISO C99
105*fd82c4c4Schristos    and POSIX.  */
106*fd82c4c4Schristos #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
107*fd82c4c4Schristos # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
108*fd82c4c4Schristos    _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
109*fd82c4c4Schristos #else
110*fd82c4c4Schristos # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
111*fd82c4c4Schristos    _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
112*fd82c4c4Schristos #endif
113*fd82c4c4Schristos 
114*fd82c4c4Schristos /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
115*fd82c4c4Schristos    except that it indicates to GCC that the supported format string directives
116*fd82c4c4Schristos    are the ones of the system scanf(), rather than the ones standardized by
117*fd82c4c4Schristos    ISO C99 and POSIX.  */
118*fd82c4c4Schristos #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
119*fd82c4c4Schristos   _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
120*fd82c4c4Schristos 
121*fd82c4c4Schristos /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>.  */
122*fd82c4c4Schristos /* But in any case avoid namespace pollution on glibc systems.  */
123*fd82c4c4Schristos #if (0 || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
124*fd82c4c4Schristos     && ! defined __GLIBC__
125*fd82c4c4Schristos # include <unistd.h>
126*fd82c4c4Schristos #endif
127*fd82c4c4Schristos 
128*fd82c4c4Schristos /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
129*fd82c4c4Schristos /* But in any case avoid namespace pollution on glibc systems.  */
130*fd82c4c4Schristos #if (0 || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
131*fd82c4c4Schristos     && ! defined __GLIBC__
132*fd82c4c4Schristos # include <sys/stat.h>
133*fd82c4c4Schristos #endif
134*fd82c4c4Schristos 
135*fd82c4c4Schristos /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
136*fd82c4c4Schristos    it before we  #define perror rpl_perror.  */
137*fd82c4c4Schristos /* But in any case avoid namespace pollution on glibc systems.  */
138*fd82c4c4Schristos #if (0 || defined GNULIB_POSIXCHECK) \
139*fd82c4c4Schristos     && (defined _WIN32 && ! defined __CYGWIN__) \
140*fd82c4c4Schristos     && ! defined __GLIBC__
141*fd82c4c4Schristos # include <stdlib.h>
142*fd82c4c4Schristos #endif
143*fd82c4c4Schristos 
144*fd82c4c4Schristos /* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
145*fd82c4c4Schristos    it before we  #define remove rpl_remove.  */
146*fd82c4c4Schristos /* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  We must include
147*fd82c4c4Schristos    it before we  #define rename rpl_rename.  */
148*fd82c4c4Schristos /* But in any case avoid namespace pollution on glibc systems.  */
149*fd82c4c4Schristos #if (0 || 1 || defined GNULIB_POSIXCHECK) \
150*fd82c4c4Schristos     && (defined _WIN32 && ! defined __CYGWIN__) \
151*fd82c4c4Schristos     && ! defined __GLIBC__
152*fd82c4c4Schristos # include <io.h>
153*fd82c4c4Schristos #endif
154*fd82c4c4Schristos 
155*fd82c4c4Schristos 
156*fd82c4c4Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
157*fd82c4c4Schristos /* C++ compatible function declaration macros.
158*fd82c4c4Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
159*fd82c4c4Schristos 
160*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
161*fd82c4c4Schristos    under the terms of the GNU General Public License as published
162*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
163*fd82c4c4Schristos    (at your option) any later version.
164*fd82c4c4Schristos 
165*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
166*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
167*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
168*fd82c4c4Schristos    General Public License for more details.
169*fd82c4c4Schristos 
170*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
171*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
172*fd82c4c4Schristos 
173*fd82c4c4Schristos #ifndef _GL_CXXDEFS_H
174*fd82c4c4Schristos #define _GL_CXXDEFS_H
175*fd82c4c4Schristos 
176*fd82c4c4Schristos /* Begin/end the GNULIB_NAMESPACE namespace.  */
177*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
178*fd82c4c4Schristos # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
179*fd82c4c4Schristos # define _GL_END_NAMESPACE }
180*fd82c4c4Schristos #else
181*fd82c4c4Schristos # define _GL_BEGIN_NAMESPACE
182*fd82c4c4Schristos # define _GL_END_NAMESPACE
183*fd82c4c4Schristos #endif
184*fd82c4c4Schristos 
185*fd82c4c4Schristos /* The three most frequent use cases of these macros are:
186*fd82c4c4Schristos 
187*fd82c4c4Schristos    * For providing a substitute for a function that is missing on some
188*fd82c4c4Schristos      platforms, but is declared and works fine on the platforms on which
189*fd82c4c4Schristos      it exists:
190*fd82c4c4Schristos 
191*fd82c4c4Schristos        #if @GNULIB_FOO@
192*fd82c4c4Schristos        # if !@HAVE_FOO@
193*fd82c4c4Schristos        _GL_FUNCDECL_SYS (foo, ...);
194*fd82c4c4Schristos        # endif
195*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
196*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
197*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
198*fd82c4c4Schristos        ...
199*fd82c4c4Schristos        #endif
200*fd82c4c4Schristos 
201*fd82c4c4Schristos    * For providing a replacement for a function that exists on all platforms,
202*fd82c4c4Schristos      but is broken/insufficient and needs to be replaced on some platforms:
203*fd82c4c4Schristos 
204*fd82c4c4Schristos        #if @GNULIB_FOO@
205*fd82c4c4Schristos        # if @REPLACE_FOO@
206*fd82c4c4Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
207*fd82c4c4Schristos        #   undef foo
208*fd82c4c4Schristos        #   define foo rpl_foo
209*fd82c4c4Schristos        #  endif
210*fd82c4c4Schristos        _GL_FUNCDECL_RPL (foo, ...);
211*fd82c4c4Schristos        _GL_CXXALIAS_RPL (foo, ...);
212*fd82c4c4Schristos        # else
213*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
214*fd82c4c4Schristos        # endif
215*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
216*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
217*fd82c4c4Schristos        ...
218*fd82c4c4Schristos        #endif
219*fd82c4c4Schristos 
220*fd82c4c4Schristos    * For providing a replacement for a function that exists on some platforms
221*fd82c4c4Schristos      but is broken/insufficient and needs to be replaced on some of them and
222*fd82c4c4Schristos      is additionally either missing or undeclared on some other platforms:
223*fd82c4c4Schristos 
224*fd82c4c4Schristos        #if @GNULIB_FOO@
225*fd82c4c4Schristos        # if @REPLACE_FOO@
226*fd82c4c4Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
227*fd82c4c4Schristos        #   undef foo
228*fd82c4c4Schristos        #   define foo rpl_foo
229*fd82c4c4Schristos        #  endif
230*fd82c4c4Schristos        _GL_FUNCDECL_RPL (foo, ...);
231*fd82c4c4Schristos        _GL_CXXALIAS_RPL (foo, ...);
232*fd82c4c4Schristos        # else
233*fd82c4c4Schristos        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
234*fd82c4c4Schristos        _GL_FUNCDECL_SYS (foo, ...);
235*fd82c4c4Schristos        #  endif
236*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
237*fd82c4c4Schristos        # endif
238*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
239*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
240*fd82c4c4Schristos        ...
241*fd82c4c4Schristos        #endif
242*fd82c4c4Schristos */
243*fd82c4c4Schristos 
244*fd82c4c4Schristos /* _GL_EXTERN_C declaration;
245*fd82c4c4Schristos    performs the declaration with C linkage.  */
246*fd82c4c4Schristos #if defined __cplusplus
247*fd82c4c4Schristos # define _GL_EXTERN_C extern "C"
248*fd82c4c4Schristos #else
249*fd82c4c4Schristos # define _GL_EXTERN_C extern
250*fd82c4c4Schristos #endif
251*fd82c4c4Schristos 
252*fd82c4c4Schristos /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
253*fd82c4c4Schristos    declares a replacement function, named rpl_func, with the given prototype,
254*fd82c4c4Schristos    consisting of return type, parameters, and attributes.
255*fd82c4c4Schristos    Example:
256*fd82c4c4Schristos      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
257*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
258*fd82c4c4Schristos  */
259*fd82c4c4Schristos #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
260*fd82c4c4Schristos   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
261*fd82c4c4Schristos #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
262*fd82c4c4Schristos   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
263*fd82c4c4Schristos 
264*fd82c4c4Schristos /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
265*fd82c4c4Schristos    declares the system function, named func, with the given prototype,
266*fd82c4c4Schristos    consisting of return type, parameters, and attributes.
267*fd82c4c4Schristos    Example:
268*fd82c4c4Schristos      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
269*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
270*fd82c4c4Schristos  */
271*fd82c4c4Schristos #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
272*fd82c4c4Schristos   _GL_EXTERN_C rettype func parameters_and_attributes
273*fd82c4c4Schristos 
274*fd82c4c4Schristos /* _GL_CXXALIAS_RPL (func, rettype, parameters);
275*fd82c4c4Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
276*fd82c4c4Schristos    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
277*fd82c4c4Schristos    Example:
278*fd82c4c4Schristos      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
279*fd82c4c4Schristos 
280*fd82c4c4Schristos    Wrapping rpl_func in an object with an inline conversion operator
281*fd82c4c4Schristos    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
282*fd82c4c4Schristos    actually used in the program.  */
283*fd82c4c4Schristos #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
284*fd82c4c4Schristos   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
285*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
286*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
287*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                \
288*fd82c4c4Schristos     {                                                         \
289*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper            \
290*fd82c4c4Schristos       {                                                       \
291*fd82c4c4Schristos         typedef rettype (*type) parameters;                   \
292*fd82c4c4Schristos                                                               \
293*fd82c4c4Schristos         inline operator type () const                         \
294*fd82c4c4Schristos         {                                                     \
295*fd82c4c4Schristos           return ::rpl_func;                                  \
296*fd82c4c4Schristos         }                                                     \
297*fd82c4c4Schristos       } func = {};                                            \
298*fd82c4c4Schristos     }                                                         \
299*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
300*fd82c4c4Schristos #else
301*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
302*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
303*fd82c4c4Schristos #endif
304*fd82c4c4Schristos 
305*fd82c4c4Schristos /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
306*fd82c4c4Schristos    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
307*fd82c4c4Schristos    except that the C function rpl_func may have a slightly different
308*fd82c4c4Schristos    declaration.  A cast is used to silence the "invalid conversion" error
309*fd82c4c4Schristos    that would otherwise occur.  */
310*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
311*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
312*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                     \
313*fd82c4c4Schristos     {                                                              \
314*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper                 \
315*fd82c4c4Schristos       {                                                            \
316*fd82c4c4Schristos         typedef rettype (*type) parameters;                        \
317*fd82c4c4Schristos                                                                    \
318*fd82c4c4Schristos         inline operator type () const                              \
319*fd82c4c4Schristos         {                                                          \
320*fd82c4c4Schristos           return reinterpret_cast<type>(::rpl_func);               \
321*fd82c4c4Schristos         }                                                          \
322*fd82c4c4Schristos       } func = {};                                                 \
323*fd82c4c4Schristos     }                                                              \
324*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
325*fd82c4c4Schristos #else
326*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
327*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
328*fd82c4c4Schristos #endif
329*fd82c4c4Schristos 
330*fd82c4c4Schristos /* _GL_CXXALIAS_SYS (func, rettype, parameters);
331*fd82c4c4Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
332*fd82c4c4Schristos    that redirects to the system provided function func, if GNULIB_NAMESPACE
333*fd82c4c4Schristos    is defined.
334*fd82c4c4Schristos    Example:
335*fd82c4c4Schristos      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
336*fd82c4c4Schristos 
337*fd82c4c4Schristos    Wrapping func in an object with an inline conversion operator
338*fd82c4c4Schristos    avoids a reference to func unless GNULIB_NAMESPACE::func is
339*fd82c4c4Schristos    actually used in the program.  */
340*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
341*fd82c4c4Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
342*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                \
343*fd82c4c4Schristos     {                                                         \
344*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper            \
345*fd82c4c4Schristos       {                                                       \
346*fd82c4c4Schristos         typedef rettype (*type) parameters;                   \
347*fd82c4c4Schristos                                                               \
348*fd82c4c4Schristos         inline operator type () const                         \
349*fd82c4c4Schristos         {                                                     \
350*fd82c4c4Schristos           return ::func;                                      \
351*fd82c4c4Schristos         }                                                     \
352*fd82c4c4Schristos       } func = {};                                            \
353*fd82c4c4Schristos     }                                                         \
354*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
355*fd82c4c4Schristos #else
356*fd82c4c4Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
357*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
358*fd82c4c4Schristos #endif
359*fd82c4c4Schristos 
360*fd82c4c4Schristos /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
361*fd82c4c4Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
362*fd82c4c4Schristos    except that the C function func may have a slightly different declaration.
363*fd82c4c4Schristos    A cast is used to silence the "invalid conversion" error that would
364*fd82c4c4Schristos    otherwise occur.  */
365*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
366*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
367*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                          \
368*fd82c4c4Schristos     {                                                   \
369*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper      \
370*fd82c4c4Schristos       {                                                 \
371*fd82c4c4Schristos         typedef rettype (*type) parameters;             \
372*fd82c4c4Schristos                                                         \
373*fd82c4c4Schristos         inline operator type () const                   \
374*fd82c4c4Schristos         {                                               \
375*fd82c4c4Schristos           return reinterpret_cast<type>(::func);        \
376*fd82c4c4Schristos         }                                               \
377*fd82c4c4Schristos       } func = {};                                      \
378*fd82c4c4Schristos     }                                                   \
379*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
380*fd82c4c4Schristos #else
381*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
382*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
383*fd82c4c4Schristos #endif
384*fd82c4c4Schristos 
385*fd82c4c4Schristos /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
386*fd82c4c4Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
387*fd82c4c4Schristos    except that the C function is picked among a set of overloaded functions,
388*fd82c4c4Schristos    namely the one with rettype2 and parameters2.  Two consecutive casts
389*fd82c4c4Schristos    are used to silence the "cannot find a match" and "invalid conversion"
390*fd82c4c4Schristos    errors that would otherwise occur.  */
391*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
392*fd82c4c4Schristos   /* The outer cast must be a reinterpret_cast.
393*fd82c4c4Schristos      The inner cast: When the function is defined as a set of overloaded
394*fd82c4c4Schristos      functions, it works as a static_cast<>, choosing the designated variant.
395*fd82c4c4Schristos      When the function is defined as a single variant, it works as a
396*fd82c4c4Schristos      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
397*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
398*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                                \
399*fd82c4c4Schristos     {                                                                         \
400*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper                            \
401*fd82c4c4Schristos       {                                                                       \
402*fd82c4c4Schristos         typedef rettype (*type) parameters;                                   \
403*fd82c4c4Schristos                                                                               \
404*fd82c4c4Schristos         inline operator type () const                                         \
405*fd82c4c4Schristos         {                                                                     \
406*fd82c4c4Schristos           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
407*fd82c4c4Schristos         }                                                                     \
408*fd82c4c4Schristos       } func = {};                                                            \
409*fd82c4c4Schristos     }                                                                         \
410*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
411*fd82c4c4Schristos #else
412*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
413*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
414*fd82c4c4Schristos #endif
415*fd82c4c4Schristos 
416*fd82c4c4Schristos /* _GL_CXXALIASWARN (func);
417*fd82c4c4Schristos    causes a warning to be emitted when ::func is used but not when
418*fd82c4c4Schristos    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
419*fd82c4c4Schristos    variants.  */
420*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
421*fd82c4c4Schristos # define _GL_CXXALIASWARN(func) \
422*fd82c4c4Schristos    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
423*fd82c4c4Schristos # define _GL_CXXALIASWARN_1(func,namespace) \
424*fd82c4c4Schristos    _GL_CXXALIASWARN_2 (func, namespace)
425*fd82c4c4Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
426*fd82c4c4Schristos    we enable the warning only when not optimizing.  */
427*fd82c4c4Schristos # if !__OPTIMIZE__
428*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
429*fd82c4c4Schristos     _GL_WARN_ON_USE (func, \
430*fd82c4c4Schristos                      "The symbol ::" #func " refers to the system function. " \
431*fd82c4c4Schristos                      "Use " #namespace "::" #func " instead.")
432*fd82c4c4Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
433*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
434*fd82c4c4Schristos      extern __typeof__ (func) func
435*fd82c4c4Schristos # else
436*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
437*fd82c4c4Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
438*fd82c4c4Schristos # endif
439*fd82c4c4Schristos #else
440*fd82c4c4Schristos # define _GL_CXXALIASWARN(func) \
441*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
442*fd82c4c4Schristos #endif
443*fd82c4c4Schristos 
444*fd82c4c4Schristos /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
445*fd82c4c4Schristos    causes a warning to be emitted when the given overloaded variant of ::func
446*fd82c4c4Schristos    is used but not when GNULIB_NAMESPACE::func is used.  */
447*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
448*fd82c4c4Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
449*fd82c4c4Schristos    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
450*fd82c4c4Schristos                         GNULIB_NAMESPACE)
451*fd82c4c4Schristos # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
452*fd82c4c4Schristos    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
453*fd82c4c4Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
454*fd82c4c4Schristos    we enable the warning only when not optimizing.  */
455*fd82c4c4Schristos # if !__OPTIMIZE__
456*fd82c4c4Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
457*fd82c4c4Schristos     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
458*fd82c4c4Schristos                          "The symbol ::" #func " refers to the system function. " \
459*fd82c4c4Schristos                          "Use " #namespace "::" #func " instead.")
460*fd82c4c4Schristos # else
461*fd82c4c4Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
462*fd82c4c4Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
463*fd82c4c4Schristos # endif
464*fd82c4c4Schristos #else
465*fd82c4c4Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
466*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
467*fd82c4c4Schristos #endif
468*fd82c4c4Schristos 
469*fd82c4c4Schristos #endif /* _GL_CXXDEFS_H */
470*fd82c4c4Schristos 
471*fd82c4c4Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
472*fd82c4c4Schristos /* A C macro for declaring that specific arguments must not be NULL.
473*fd82c4c4Schristos    Copyright (C) 2009-2020 Free Software Foundation, Inc.
474*fd82c4c4Schristos 
475*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
476*fd82c4c4Schristos    under the terms of the GNU General Public License as published
477*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
478*fd82c4c4Schristos    (at your option) any later version.
479*fd82c4c4Schristos 
480*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
481*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
482*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
483*fd82c4c4Schristos    General Public License for more details.
484*fd82c4c4Schristos 
485*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
486*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
487*fd82c4c4Schristos 
488*fd82c4c4Schristos /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
489*fd82c4c4Schristos    that the values passed as arguments n, ..., m must be non-NULL pointers.
490*fd82c4c4Schristos    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
491*fd82c4c4Schristos #ifndef _GL_ARG_NONNULL
492*fd82c4c4Schristos # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
493*fd82c4c4Schristos #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
494*fd82c4c4Schristos # else
495*fd82c4c4Schristos #  define _GL_ARG_NONNULL(params)
496*fd82c4c4Schristos # endif
497*fd82c4c4Schristos #endif
498*fd82c4c4Schristos 
499*fd82c4c4Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
500*fd82c4c4Schristos /* A C macro for emitting warnings if a function is used.
501*fd82c4c4Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
502*fd82c4c4Schristos 
503*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
504*fd82c4c4Schristos    under the terms of the GNU General Public License as published
505*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
506*fd82c4c4Schristos    (at your option) any later version.
507*fd82c4c4Schristos 
508*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
509*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
510*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
511*fd82c4c4Schristos    General Public License for more details.
512*fd82c4c4Schristos 
513*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
514*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
515*fd82c4c4Schristos 
516*fd82c4c4Schristos /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
517*fd82c4c4Schristos    for FUNCTION which will then trigger a compiler warning containing
518*fd82c4c4Schristos    the text of "literal string" anywhere that function is called, if
519*fd82c4c4Schristos    supported by the compiler.  If the compiler does not support this
520*fd82c4c4Schristos    feature, the macro expands to an unused extern declaration.
521*fd82c4c4Schristos 
522*fd82c4c4Schristos    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
523*fd82c4c4Schristos    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
524*fd82c4c4Schristos    this feature, it expands to empty.
525*fd82c4c4Schristos 
526*fd82c4c4Schristos    These macros are useful for marking a function as a potential
527*fd82c4c4Schristos    portability trap, with the intent that "literal string" include
528*fd82c4c4Schristos    instructions on the replacement function that should be used
529*fd82c4c4Schristos    instead.
530*fd82c4c4Schristos    _GL_WARN_ON_USE is for functions with 'extern' linkage.
531*fd82c4c4Schristos    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
532*fd82c4c4Schristos    linkage.
533*fd82c4c4Schristos 
534*fd82c4c4Schristos    However, one of the reasons that a function is a portability trap is
535*fd82c4c4Schristos    if it has the wrong signature.  Declaring FUNCTION with a different
536*fd82c4c4Schristos    signature in C is a compilation error, so this macro must use the
537*fd82c4c4Schristos    same type as any existing declaration so that programs that avoid
538*fd82c4c4Schristos    the problematic FUNCTION do not fail to compile merely because they
539*fd82c4c4Schristos    included a header that poisoned the function.  But this implies that
540*fd82c4c4Schristos    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
541*fd82c4c4Schristos    have a declaration.  Use of this macro implies that there must not
542*fd82c4c4Schristos    be any other macro hiding the declaration of FUNCTION; but
543*fd82c4c4Schristos    undefining FUNCTION first is part of the poisoning process anyway
544*fd82c4c4Schristos    (although for symbols that are provided only via a macro, the result
545*fd82c4c4Schristos    is a compilation error rather than a warning containing
546*fd82c4c4Schristos    "literal string").  Also note that in C++, it is only safe to use if
547*fd82c4c4Schristos    FUNCTION has no overloads.
548*fd82c4c4Schristos 
549*fd82c4c4Schristos    For an example, it is possible to poison 'getline' by:
550*fd82c4c4Schristos    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
551*fd82c4c4Schristos      [getline]) in configure.ac, which potentially defines
552*fd82c4c4Schristos      HAVE_RAW_DECL_GETLINE
553*fd82c4c4Schristos    - adding this code to a header that wraps the system <stdio.h>:
554*fd82c4c4Schristos      #undef getline
555*fd82c4c4Schristos      #if HAVE_RAW_DECL_GETLINE
556*fd82c4c4Schristos      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
557*fd82c4c4Schristos        "not universally present; use the gnulib module getline");
558*fd82c4c4Schristos      #endif
559*fd82c4c4Schristos 
560*fd82c4c4Schristos    It is not possible to directly poison global variables.  But it is
561*fd82c4c4Schristos    possible to write a wrapper accessor function, and poison that
562*fd82c4c4Schristos    (less common usage, like &environ, will cause a compilation error
563*fd82c4c4Schristos    rather than issue the nice warning, but the end result of informing
564*fd82c4c4Schristos    the developer about their portability problem is still achieved):
565*fd82c4c4Schristos      #if HAVE_RAW_DECL_ENVIRON
566*fd82c4c4Schristos      static char ***
567*fd82c4c4Schristos      rpl_environ (void) { return &environ; }
568*fd82c4c4Schristos      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
569*fd82c4c4Schristos      # undef environ
570*fd82c4c4Schristos      # define environ (*rpl_environ ())
571*fd82c4c4Schristos      #endif
572*fd82c4c4Schristos    or better (avoiding contradictory use of 'static' and 'extern'):
573*fd82c4c4Schristos      #if HAVE_RAW_DECL_ENVIRON
574*fd82c4c4Schristos      static char ***
575*fd82c4c4Schristos      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
576*fd82c4c4Schristos      rpl_environ (void) { return &environ; }
577*fd82c4c4Schristos      # undef environ
578*fd82c4c4Schristos      # define environ (*rpl_environ ())
579*fd82c4c4Schristos      #endif
580*fd82c4c4Schristos    */
581*fd82c4c4Schristos #ifndef _GL_WARN_ON_USE
582*fd82c4c4Schristos 
583*fd82c4c4Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
584*fd82c4c4Schristos /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
585*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
586*fd82c4c4Schristos extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
587*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
588*fd82c4c4Schristos   __attribute__ ((__warning__ (message)))
589*fd82c4c4Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
590*fd82c4c4Schristos /* Verify the existence of the function.  */
591*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
592*fd82c4c4Schristos extern __typeof__ (function) function
593*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
594*fd82c4c4Schristos # else /* Unsupported.  */
595*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
596*fd82c4c4Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
597*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
598*fd82c4c4Schristos # endif
599*fd82c4c4Schristos #endif
600*fd82c4c4Schristos 
601*fd82c4c4Schristos /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
602*fd82c4c4Schristos    is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
603*fd82c4c4Schristos    function is declared with the given prototype, consisting of return type,
604*fd82c4c4Schristos    parameters, and attributes.
605*fd82c4c4Schristos    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
606*fd82c4c4Schristos    not work in this case.  */
607*fd82c4c4Schristos #ifndef _GL_WARN_ON_USE_CXX
608*fd82c4c4Schristos # if !defined __cplusplus
609*fd82c4c4Schristos #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
610*fd82c4c4Schristos      _GL_WARN_ON_USE (function, msg)
611*fd82c4c4Schristos # else
612*fd82c4c4Schristos #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
613*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
614*fd82c4c4Schristos extern rettype function parameters_and_attributes \
615*fd82c4c4Schristos      __attribute__ ((__warning__ (msg)))
616*fd82c4c4Schristos #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
617*fd82c4c4Schristos /* Verify the existence of the function.  */
618*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
619*fd82c4c4Schristos extern rettype function parameters_and_attributes
620*fd82c4c4Schristos #  else /* Unsupported.  */
621*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
622*fd82c4c4Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
623*fd82c4c4Schristos #  endif
624*fd82c4c4Schristos # endif
625*fd82c4c4Schristos #endif
626*fd82c4c4Schristos 
627*fd82c4c4Schristos /* _GL_WARN_EXTERN_C declaration;
628*fd82c4c4Schristos    performs the declaration with C linkage.  */
629*fd82c4c4Schristos #ifndef _GL_WARN_EXTERN_C
630*fd82c4c4Schristos # if defined __cplusplus
631*fd82c4c4Schristos #  define _GL_WARN_EXTERN_C extern "C"
632*fd82c4c4Schristos # else
633*fd82c4c4Schristos #  define _GL_WARN_EXTERN_C extern
634*fd82c4c4Schristos # endif
635*fd82c4c4Schristos #endif
636*fd82c4c4Schristos 
637*fd82c4c4Schristos /* Macros for stringification.  */
638*fd82c4c4Schristos #define _GL_STDIO_STRINGIZE(token) #token
639*fd82c4c4Schristos #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
640*fd82c4c4Schristos 
641*fd82c4c4Schristos /* When also using extern inline, suppress the use of static inline in
642*fd82c4c4Schristos    standard headers of problematic Apple configurations, as Libc at
643*fd82c4c4Schristos    least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
644*fd82c4c4Schristos    <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
645*fd82c4c4Schristos    Perhaps Apple will fix this some day.  */
646*fd82c4c4Schristos #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
647*fd82c4c4Schristos      && defined __GNUC__ && defined __STDC__)
648*fd82c4c4Schristos # undef putc_unlocked
649*fd82c4c4Schristos #endif
650*fd82c4c4Schristos 
651*fd82c4c4Schristos #if 0
652*fd82c4c4Schristos # if 0
653*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
654*fd82c4c4Schristos #   define dprintf rpl_dprintf
655*fd82c4c4Schristos #  endif
656*fd82c4c4Schristos _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
657*fd82c4c4Schristos                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
658*fd82c4c4Schristos                                 _GL_ARG_NONNULL ((2)));
659*fd82c4c4Schristos _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
660*fd82c4c4Schristos # else
661*fd82c4c4Schristos #  if !1
662*fd82c4c4Schristos _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
663*fd82c4c4Schristos                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
664*fd82c4c4Schristos                                 _GL_ARG_NONNULL ((2)));
665*fd82c4c4Schristos #  endif
666*fd82c4c4Schristos _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
667*fd82c4c4Schristos # endif
668*fd82c4c4Schristos _GL_CXXALIASWARN (dprintf);
669*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
670*fd82c4c4Schristos # undef dprintf
671*fd82c4c4Schristos # if HAVE_RAW_DECL_DPRINTF
672*fd82c4c4Schristos _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
673*fd82c4c4Schristos                  "use gnulib module dprintf for portability");
674*fd82c4c4Schristos # endif
675*fd82c4c4Schristos #endif
676*fd82c4c4Schristos 
677*fd82c4c4Schristos #if 0
678*fd82c4c4Schristos /* Close STREAM and its underlying file descriptor.  */
679*fd82c4c4Schristos # if 0
680*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
681*fd82c4c4Schristos #   define fclose rpl_fclose
682*fd82c4c4Schristos #  endif
683*fd82c4c4Schristos _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
684*fd82c4c4Schristos _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
685*fd82c4c4Schristos # else
686*fd82c4c4Schristos _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
687*fd82c4c4Schristos # endif
688*fd82c4c4Schristos # if __GLIBC__ >= 2
689*fd82c4c4Schristos _GL_CXXALIASWARN (fclose);
690*fd82c4c4Schristos # endif
691*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
692*fd82c4c4Schristos # undef fclose
693*fd82c4c4Schristos /* Assume fclose is always declared.  */
694*fd82c4c4Schristos _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
695*fd82c4c4Schristos                  "use gnulib module fclose for portable POSIX compliance");
696*fd82c4c4Schristos #endif
697*fd82c4c4Schristos 
698*fd82c4c4Schristos #if 0
699*fd82c4c4Schristos # if 0
700*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
701*fd82c4c4Schristos #   undef fdopen
702*fd82c4c4Schristos #   define fdopen rpl_fdopen
703*fd82c4c4Schristos #  endif
704*fd82c4c4Schristos _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
705*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((2)));
706*fd82c4c4Schristos _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
707*fd82c4c4Schristos # else
708*fd82c4c4Schristos _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
709*fd82c4c4Schristos # endif
710*fd82c4c4Schristos _GL_CXXALIASWARN (fdopen);
711*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
712*fd82c4c4Schristos # undef fdopen
713*fd82c4c4Schristos /* Assume fdopen is always declared.  */
714*fd82c4c4Schristos _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
715*fd82c4c4Schristos                  "use gnulib module fdopen for portability");
716*fd82c4c4Schristos #endif
717*fd82c4c4Schristos 
718*fd82c4c4Schristos #if 0
719*fd82c4c4Schristos /* Flush all pending data on STREAM according to POSIX rules.  Both
720*fd82c4c4Schristos    output and seekable input streams are supported.
721*fd82c4c4Schristos    Note! LOSS OF DATA can occur if fflush is applied on an input stream
722*fd82c4c4Schristos    that is _not_seekable_ or on an update stream that is _not_seekable_
723*fd82c4c4Schristos    and in which the most recent operation was input.  Seekability can
724*fd82c4c4Schristos    be tested with lseek(fileno(fp),0,SEEK_CUR).  */
725*fd82c4c4Schristos # if 0
726*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
727*fd82c4c4Schristos #   define fflush rpl_fflush
728*fd82c4c4Schristos #  endif
729*fd82c4c4Schristos _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
730*fd82c4c4Schristos _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
731*fd82c4c4Schristos # else
732*fd82c4c4Schristos _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
733*fd82c4c4Schristos # endif
734*fd82c4c4Schristos # if __GLIBC__ >= 2
735*fd82c4c4Schristos _GL_CXXALIASWARN (fflush);
736*fd82c4c4Schristos # endif
737*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
738*fd82c4c4Schristos # undef fflush
739*fd82c4c4Schristos /* Assume fflush is always declared.  */
740*fd82c4c4Schristos _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
741*fd82c4c4Schristos                  "use gnulib module fflush for portable POSIX compliance");
742*fd82c4c4Schristos #endif
743*fd82c4c4Schristos 
744*fd82c4c4Schristos #if 1
745*fd82c4c4Schristos # if 0 && 0
746*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
747*fd82c4c4Schristos #   undef fgetc
748*fd82c4c4Schristos #   define fgetc rpl_fgetc
749*fd82c4c4Schristos #  endif
750*fd82c4c4Schristos _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
751*fd82c4c4Schristos _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
752*fd82c4c4Schristos # else
753*fd82c4c4Schristos _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
754*fd82c4c4Schristos # endif
755*fd82c4c4Schristos # if __GLIBC__ >= 2
756*fd82c4c4Schristos _GL_CXXALIASWARN (fgetc);
757*fd82c4c4Schristos # endif
758*fd82c4c4Schristos #endif
759*fd82c4c4Schristos 
760*fd82c4c4Schristos #if 1
761*fd82c4c4Schristos # if 0 && 0
762*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
763*fd82c4c4Schristos #   undef fgets
764*fd82c4c4Schristos #   define fgets rpl_fgets
765*fd82c4c4Schristos #  endif
766*fd82c4c4Schristos _GL_FUNCDECL_RPL (fgets, char *,
767*fd82c4c4Schristos                   (char *restrict s, int n, FILE *restrict stream)
768*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 3)));
769*fd82c4c4Schristos _GL_CXXALIAS_RPL (fgets, char *,
770*fd82c4c4Schristos                   (char *restrict s, int n, FILE *restrict stream));
771*fd82c4c4Schristos # else
772*fd82c4c4Schristos _GL_CXXALIAS_SYS (fgets, char *,
773*fd82c4c4Schristos                   (char *restrict s, int n, FILE *restrict stream));
774*fd82c4c4Schristos # endif
775*fd82c4c4Schristos # if __GLIBC__ >= 2
776*fd82c4c4Schristos _GL_CXXALIASWARN (fgets);
777*fd82c4c4Schristos # endif
778*fd82c4c4Schristos #endif
779*fd82c4c4Schristos 
780*fd82c4c4Schristos #if 0
781*fd82c4c4Schristos # if 0
782*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
783*fd82c4c4Schristos #   undef fopen
784*fd82c4c4Schristos #   define fopen rpl_fopen
785*fd82c4c4Schristos #  endif
786*fd82c4c4Schristos _GL_FUNCDECL_RPL (fopen, FILE *,
787*fd82c4c4Schristos                   (const char *restrict filename, const char *restrict mode)
788*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
789*fd82c4c4Schristos _GL_CXXALIAS_RPL (fopen, FILE *,
790*fd82c4c4Schristos                   (const char *restrict filename, const char *restrict mode));
791*fd82c4c4Schristos # else
792*fd82c4c4Schristos _GL_CXXALIAS_SYS (fopen, FILE *,
793*fd82c4c4Schristos                   (const char *restrict filename, const char *restrict mode));
794*fd82c4c4Schristos # endif
795*fd82c4c4Schristos # if __GLIBC__ >= 2
796*fd82c4c4Schristos _GL_CXXALIASWARN (fopen);
797*fd82c4c4Schristos # endif
798*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
799*fd82c4c4Schristos # undef fopen
800*fd82c4c4Schristos /* Assume fopen is always declared.  */
801*fd82c4c4Schristos _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
802*fd82c4c4Schristos                  "use gnulib module fopen for portability");
803*fd82c4c4Schristos #endif
804*fd82c4c4Schristos 
805*fd82c4c4Schristos #if 0 || 1
806*fd82c4c4Schristos # if (0 && 0) \
807*fd82c4c4Schristos      || (1 && 0 && (0 || 0))
808*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809*fd82c4c4Schristos #   define fprintf rpl_fprintf
810*fd82c4c4Schristos #  endif
811*fd82c4c4Schristos #  define GNULIB_overrides_fprintf 1
812*fd82c4c4Schristos #  if 0 || 0
813*fd82c4c4Schristos _GL_FUNCDECL_RPL (fprintf, int,
814*fd82c4c4Schristos                   (FILE *restrict fp, const char *restrict format, ...)
815*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
816*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
817*fd82c4c4Schristos #  else
818*fd82c4c4Schristos _GL_FUNCDECL_RPL (fprintf, int,
819*fd82c4c4Schristos                   (FILE *restrict fp, const char *restrict format, ...)
820*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
821*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
822*fd82c4c4Schristos #  endif
823*fd82c4c4Schristos _GL_CXXALIAS_RPL (fprintf, int,
824*fd82c4c4Schristos                   (FILE *restrict fp, const char *restrict format, ...));
825*fd82c4c4Schristos # else
826*fd82c4c4Schristos _GL_CXXALIAS_SYS (fprintf, int,
827*fd82c4c4Schristos                   (FILE *restrict fp, const char *restrict format, ...));
828*fd82c4c4Schristos # endif
829*fd82c4c4Schristos # if __GLIBC__ >= 2
830*fd82c4c4Schristos _GL_CXXALIASWARN (fprintf);
831*fd82c4c4Schristos # endif
832*fd82c4c4Schristos #endif
833*fd82c4c4Schristos #if !0 && defined GNULIB_POSIXCHECK
834*fd82c4c4Schristos # if !GNULIB_overrides_fprintf
835*fd82c4c4Schristos #  undef fprintf
836*fd82c4c4Schristos # endif
837*fd82c4c4Schristos /* Assume fprintf is always declared.  */
838*fd82c4c4Schristos _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
839*fd82c4c4Schristos                  "use gnulib module fprintf-posix for portable "
840*fd82c4c4Schristos                  "POSIX compliance");
841*fd82c4c4Schristos #endif
842*fd82c4c4Schristos 
843*fd82c4c4Schristos #if 0
844*fd82c4c4Schristos /* Discard all pending buffered I/O data on STREAM.
845*fd82c4c4Schristos    STREAM must not be wide-character oriented.
846*fd82c4c4Schristos    When discarding pending output, the file position is set back to where it
847*fd82c4c4Schristos    was before the write calls.  When discarding pending input, the file
848*fd82c4c4Schristos    position is advanced to match the end of the previously read input.
849*fd82c4c4Schristos    Return 0 if successful.  Upon error, return -1 and set errno.  */
850*fd82c4c4Schristos # if 0
851*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
852*fd82c4c4Schristos #   define fpurge rpl_fpurge
853*fd82c4c4Schristos #  endif
854*fd82c4c4Schristos _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
855*fd82c4c4Schristos _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
856*fd82c4c4Schristos # else
857*fd82c4c4Schristos #  if !1
858*fd82c4c4Schristos _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
859*fd82c4c4Schristos #  endif
860*fd82c4c4Schristos _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
861*fd82c4c4Schristos # endif
862*fd82c4c4Schristos _GL_CXXALIASWARN (fpurge);
863*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
864*fd82c4c4Schristos # undef fpurge
865*fd82c4c4Schristos # if HAVE_RAW_DECL_FPURGE
866*fd82c4c4Schristos _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
867*fd82c4c4Schristos                  "use gnulib module fpurge for portability");
868*fd82c4c4Schristos # endif
869*fd82c4c4Schristos #endif
870*fd82c4c4Schristos 
871*fd82c4c4Schristos #if 1
872*fd82c4c4Schristos # if 0 && (0 || 0)
873*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
874*fd82c4c4Schristos #   undef fputc
875*fd82c4c4Schristos #   define fputc rpl_fputc
876*fd82c4c4Schristos #  endif
877*fd82c4c4Schristos _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
878*fd82c4c4Schristos _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
879*fd82c4c4Schristos # else
880*fd82c4c4Schristos _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
881*fd82c4c4Schristos # endif
882*fd82c4c4Schristos # if __GLIBC__ >= 2
883*fd82c4c4Schristos _GL_CXXALIASWARN (fputc);
884*fd82c4c4Schristos # endif
885*fd82c4c4Schristos #endif
886*fd82c4c4Schristos 
887*fd82c4c4Schristos #if 1
888*fd82c4c4Schristos # if 0 && (0 || 0)
889*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
890*fd82c4c4Schristos #   undef fputs
891*fd82c4c4Schristos #   define fputs rpl_fputs
892*fd82c4c4Schristos #  endif
893*fd82c4c4Schristos _GL_FUNCDECL_RPL (fputs, int,
894*fd82c4c4Schristos                   (const char *restrict string, FILE *restrict stream)
895*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
896*fd82c4c4Schristos _GL_CXXALIAS_RPL (fputs, int,
897*fd82c4c4Schristos                   (const char *restrict string, FILE *restrict stream));
898*fd82c4c4Schristos # else
899*fd82c4c4Schristos _GL_CXXALIAS_SYS (fputs, int,
900*fd82c4c4Schristos                   (const char *restrict string, FILE *restrict stream));
901*fd82c4c4Schristos # endif
902*fd82c4c4Schristos # if __GLIBC__ >= 2
903*fd82c4c4Schristos _GL_CXXALIASWARN (fputs);
904*fd82c4c4Schristos # endif
905*fd82c4c4Schristos #endif
906*fd82c4c4Schristos 
907*fd82c4c4Schristos #if 1
908*fd82c4c4Schristos # if 0 && 0
909*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
910*fd82c4c4Schristos #   undef fread
911*fd82c4c4Schristos #   define fread rpl_fread
912*fd82c4c4Schristos #  endif
913*fd82c4c4Schristos _GL_FUNCDECL_RPL (fread, size_t,
914*fd82c4c4Schristos                   (void *restrict ptr, size_t s, size_t n,
915*fd82c4c4Schristos                    FILE *restrict stream)
916*fd82c4c4Schristos                   _GL_ARG_NONNULL ((4)));
917*fd82c4c4Schristos _GL_CXXALIAS_RPL (fread, size_t,
918*fd82c4c4Schristos                   (void *restrict ptr, size_t s, size_t n,
919*fd82c4c4Schristos                    FILE *restrict stream));
920*fd82c4c4Schristos # else
921*fd82c4c4Schristos _GL_CXXALIAS_SYS (fread, size_t,
922*fd82c4c4Schristos                   (void *restrict ptr, size_t s, size_t n,
923*fd82c4c4Schristos                    FILE *restrict stream));
924*fd82c4c4Schristos # endif
925*fd82c4c4Schristos # if __GLIBC__ >= 2
926*fd82c4c4Schristos _GL_CXXALIASWARN (fread);
927*fd82c4c4Schristos # endif
928*fd82c4c4Schristos #endif
929*fd82c4c4Schristos 
930*fd82c4c4Schristos #if 0
931*fd82c4c4Schristos # if 0
932*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
933*fd82c4c4Schristos #   undef freopen
934*fd82c4c4Schristos #   define freopen rpl_freopen
935*fd82c4c4Schristos #  endif
936*fd82c4c4Schristos _GL_FUNCDECL_RPL (freopen, FILE *,
937*fd82c4c4Schristos                   (const char *restrict filename, const char *restrict mode,
938*fd82c4c4Schristos                    FILE *restrict stream)
939*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2, 3)));
940*fd82c4c4Schristos _GL_CXXALIAS_RPL (freopen, FILE *,
941*fd82c4c4Schristos                   (const char *restrict filename, const char *restrict mode,
942*fd82c4c4Schristos                    FILE *restrict stream));
943*fd82c4c4Schristos # else
944*fd82c4c4Schristos _GL_CXXALIAS_SYS (freopen, FILE *,
945*fd82c4c4Schristos                   (const char *restrict filename, const char *restrict mode,
946*fd82c4c4Schristos                    FILE *restrict stream));
947*fd82c4c4Schristos # endif
948*fd82c4c4Schristos # if __GLIBC__ >= 2
949*fd82c4c4Schristos _GL_CXXALIASWARN (freopen);
950*fd82c4c4Schristos # endif
951*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
952*fd82c4c4Schristos # undef freopen
953*fd82c4c4Schristos /* Assume freopen is always declared.  */
954*fd82c4c4Schristos _GL_WARN_ON_USE (freopen,
955*fd82c4c4Schristos                  "freopen on native Windows platforms is not POSIX compliant - "
956*fd82c4c4Schristos                  "use gnulib module freopen for portability");
957*fd82c4c4Schristos #endif
958*fd82c4c4Schristos 
959*fd82c4c4Schristos #if 1
960*fd82c4c4Schristos # if 0 && 0
961*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
962*fd82c4c4Schristos #   undef fscanf
963*fd82c4c4Schristos #   define fscanf rpl_fscanf
964*fd82c4c4Schristos #  endif
965*fd82c4c4Schristos _GL_FUNCDECL_RPL (fscanf, int,
966*fd82c4c4Schristos                   (FILE *restrict stream, const char *restrict format, ...)
967*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
968*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
969*fd82c4c4Schristos _GL_CXXALIAS_RPL (fscanf, int,
970*fd82c4c4Schristos                   (FILE *restrict stream, const char *restrict format, ...));
971*fd82c4c4Schristos # else
972*fd82c4c4Schristos _GL_CXXALIAS_SYS (fscanf, int,
973*fd82c4c4Schristos                   (FILE *restrict stream, const char *restrict format, ...));
974*fd82c4c4Schristos # endif
975*fd82c4c4Schristos # if __GLIBC__ >= 2
976*fd82c4c4Schristos _GL_CXXALIASWARN (fscanf);
977*fd82c4c4Schristos # endif
978*fd82c4c4Schristos #endif
979*fd82c4c4Schristos 
980*fd82c4c4Schristos 
981*fd82c4c4Schristos /* Set up the following warnings, based on which modules are in use.
982*fd82c4c4Schristos    GNU Coding Standards discourage the use of fseek, since it imposes
983*fd82c4c4Schristos    an arbitrary limitation on some 32-bit hosts.  Remember that the
984*fd82c4c4Schristos    fseek module depends on the fseeko module, so we only have three
985*fd82c4c4Schristos    cases to consider:
986*fd82c4c4Schristos 
987*fd82c4c4Schristos    1. The developer is not using either module.  Issue a warning under
988*fd82c4c4Schristos    GNULIB_POSIXCHECK for both functions, to remind them that both
989*fd82c4c4Schristos    functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
990*fd82c4c4Schristos    impact on this warning.
991*fd82c4c4Schristos 
992*fd82c4c4Schristos    2. The developer is using both modules.  They may be unaware of the
993*fd82c4c4Schristos    arbitrary limitations of fseek, so issue a warning under
994*fd82c4c4Schristos    GNULIB_POSIXCHECK.  On the other hand, they may be using both
995*fd82c4c4Schristos    modules intentionally, so the developer can define
996*fd82c4c4Schristos    _GL_NO_LARGE_FILES in the compilation units where the use of fseek
997*fd82c4c4Schristos    is safe, to silence the warning.
998*fd82c4c4Schristos 
999*fd82c4c4Schristos    3. The developer is using the fseeko module, but not fseek.  Gnulib
1000*fd82c4c4Schristos    guarantees that fseek will still work around platform bugs in that
1001*fd82c4c4Schristos    case, but we presume that the developer is aware of the pitfalls of
1002*fd82c4c4Schristos    fseek and was trying to avoid it, so issue a warning even when
1003*fd82c4c4Schristos    GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
1004*fd82c4c4Schristos    defined to silence the warning in particular compilation units.
1005*fd82c4c4Schristos    In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
1006*fd82c4c4Schristos    fseek gets defined as a macro, it is recommended that the developer
1007*fd82c4c4Schristos    uses the fseek module, even if he is not calling the fseek function.
1008*fd82c4c4Schristos 
1009*fd82c4c4Schristos    Most gnulib clients that perform stream operations should fall into
1010*fd82c4c4Schristos    category 3.  */
1011*fd82c4c4Schristos 
1012*fd82c4c4Schristos #if 0
1013*fd82c4c4Schristos # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
1014*fd82c4c4Schristos #  define _GL_FSEEK_WARN /* Category 2, above.  */
1015*fd82c4c4Schristos #  undef fseek
1016*fd82c4c4Schristos # endif
1017*fd82c4c4Schristos # if 0
1018*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1019*fd82c4c4Schristos #   undef fseek
1020*fd82c4c4Schristos #   define fseek rpl_fseek
1021*fd82c4c4Schristos #  endif
1022*fd82c4c4Schristos _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
1023*fd82c4c4Schristos                               _GL_ARG_NONNULL ((1)));
1024*fd82c4c4Schristos _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
1025*fd82c4c4Schristos # else
1026*fd82c4c4Schristos _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
1027*fd82c4c4Schristos # endif
1028*fd82c4c4Schristos # if __GLIBC__ >= 2
1029*fd82c4c4Schristos _GL_CXXALIASWARN (fseek);
1030*fd82c4c4Schristos # endif
1031*fd82c4c4Schristos #endif
1032*fd82c4c4Schristos 
1033*fd82c4c4Schristos #if 0
1034*fd82c4c4Schristos # if !0 && !defined _GL_NO_LARGE_FILES
1035*fd82c4c4Schristos #  define _GL_FSEEK_WARN /* Category 3, above.  */
1036*fd82c4c4Schristos #  undef fseek
1037*fd82c4c4Schristos # endif
1038*fd82c4c4Schristos # if 0
1039*fd82c4c4Schristos /* Provide an fseeko function that is aware of a preceding fflush(), and which
1040*fd82c4c4Schristos    detects pipes.  */
1041*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1042*fd82c4c4Schristos #   undef fseeko
1043*fd82c4c4Schristos #   define fseeko rpl_fseeko
1044*fd82c4c4Schristos #  endif
1045*fd82c4c4Schristos _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
1046*fd82c4c4Schristos                                _GL_ARG_NONNULL ((1)));
1047*fd82c4c4Schristos _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
1048*fd82c4c4Schristos # else
1049*fd82c4c4Schristos #  if ! 1
1050*fd82c4c4Schristos _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
1051*fd82c4c4Schristos                                _GL_ARG_NONNULL ((1)));
1052*fd82c4c4Schristos #  endif
1053*fd82c4c4Schristos _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
1054*fd82c4c4Schristos # endif
1055*fd82c4c4Schristos _GL_CXXALIASWARN (fseeko);
1056*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1057*fd82c4c4Schristos # define _GL_FSEEK_WARN /* Category 1, above.  */
1058*fd82c4c4Schristos # undef fseek
1059*fd82c4c4Schristos # undef fseeko
1060*fd82c4c4Schristos # if HAVE_RAW_DECL_FSEEKO
1061*fd82c4c4Schristos _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
1062*fd82c4c4Schristos                  "use gnulib module fseeko for portability");
1063*fd82c4c4Schristos # endif
1064*fd82c4c4Schristos #endif
1065*fd82c4c4Schristos 
1066*fd82c4c4Schristos #ifdef _GL_FSEEK_WARN
1067*fd82c4c4Schristos # undef _GL_FSEEK_WARN
1068*fd82c4c4Schristos /* Here, either fseek is undefined (but C89 guarantees that it is
1069*fd82c4c4Schristos    declared), or it is defined as rpl_fseek (declared above).  */
1070*fd82c4c4Schristos _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
1071*fd82c4c4Schristos                  "on 32-bit platforms - "
1072*fd82c4c4Schristos                  "use fseeko function for handling of large files");
1073*fd82c4c4Schristos #endif
1074*fd82c4c4Schristos 
1075*fd82c4c4Schristos 
1076*fd82c4c4Schristos /* ftell, ftello.  See the comments on fseek/fseeko.  */
1077*fd82c4c4Schristos 
1078*fd82c4c4Schristos #if 0
1079*fd82c4c4Schristos # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
1080*fd82c4c4Schristos #  define _GL_FTELL_WARN /* Category 2, above.  */
1081*fd82c4c4Schristos #  undef ftell
1082*fd82c4c4Schristos # endif
1083*fd82c4c4Schristos # if 0
1084*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085*fd82c4c4Schristos #   undef ftell
1086*fd82c4c4Schristos #   define ftell rpl_ftell
1087*fd82c4c4Schristos #  endif
1088*fd82c4c4Schristos _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
1089*fd82c4c4Schristos _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
1090*fd82c4c4Schristos # else
1091*fd82c4c4Schristos _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
1092*fd82c4c4Schristos # endif
1093*fd82c4c4Schristos # if __GLIBC__ >= 2
1094*fd82c4c4Schristos _GL_CXXALIASWARN (ftell);
1095*fd82c4c4Schristos # endif
1096*fd82c4c4Schristos #endif
1097*fd82c4c4Schristos 
1098*fd82c4c4Schristos #if 0
1099*fd82c4c4Schristos # if !0 && !defined _GL_NO_LARGE_FILES
1100*fd82c4c4Schristos #  define _GL_FTELL_WARN /* Category 3, above.  */
1101*fd82c4c4Schristos #  undef ftell
1102*fd82c4c4Schristos # endif
1103*fd82c4c4Schristos # if 0
1104*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1105*fd82c4c4Schristos #   undef ftello
1106*fd82c4c4Schristos #   define ftello rpl_ftello
1107*fd82c4c4Schristos #  endif
1108*fd82c4c4Schristos _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
1109*fd82c4c4Schristos _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
1110*fd82c4c4Schristos # else
1111*fd82c4c4Schristos #  if ! 1
1112*fd82c4c4Schristos _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
1113*fd82c4c4Schristos #  endif
1114*fd82c4c4Schristos _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
1115*fd82c4c4Schristos # endif
1116*fd82c4c4Schristos _GL_CXXALIASWARN (ftello);
1117*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1118*fd82c4c4Schristos # define _GL_FTELL_WARN /* Category 1, above.  */
1119*fd82c4c4Schristos # undef ftell
1120*fd82c4c4Schristos # undef ftello
1121*fd82c4c4Schristos # if HAVE_RAW_DECL_FTELLO
1122*fd82c4c4Schristos _GL_WARN_ON_USE (ftello, "ftello is unportable - "
1123*fd82c4c4Schristos                  "use gnulib module ftello for portability");
1124*fd82c4c4Schristos # endif
1125*fd82c4c4Schristos #endif
1126*fd82c4c4Schristos 
1127*fd82c4c4Schristos #ifdef _GL_FTELL_WARN
1128*fd82c4c4Schristos # undef _GL_FTELL_WARN
1129*fd82c4c4Schristos /* Here, either ftell is undefined (but C89 guarantees that it is
1130*fd82c4c4Schristos    declared), or it is defined as rpl_ftell (declared above).  */
1131*fd82c4c4Schristos _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
1132*fd82c4c4Schristos                  "on 32-bit platforms - "
1133*fd82c4c4Schristos                  "use ftello function for handling of large files");
1134*fd82c4c4Schristos #endif
1135*fd82c4c4Schristos 
1136*fd82c4c4Schristos 
1137*fd82c4c4Schristos #if 1
1138*fd82c4c4Schristos # if 0 && (0 || 0)
1139*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1140*fd82c4c4Schristos #   undef fwrite
1141*fd82c4c4Schristos #   define fwrite rpl_fwrite
1142*fd82c4c4Schristos #  endif
1143*fd82c4c4Schristos _GL_FUNCDECL_RPL (fwrite, size_t,
1144*fd82c4c4Schristos                   (const void *restrict ptr, size_t s, size_t n,
1145*fd82c4c4Schristos                    FILE *restrict stream)
1146*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 4)));
1147*fd82c4c4Schristos _GL_CXXALIAS_RPL (fwrite, size_t,
1148*fd82c4c4Schristos                   (const void *restrict ptr, size_t s, size_t n,
1149*fd82c4c4Schristos                    FILE *restrict stream));
1150*fd82c4c4Schristos # else
1151*fd82c4c4Schristos _GL_CXXALIAS_SYS (fwrite, size_t,
1152*fd82c4c4Schristos                   (const void *restrict ptr, size_t s, size_t n,
1153*fd82c4c4Schristos                    FILE *restrict stream));
1154*fd82c4c4Schristos 
1155*fd82c4c4Schristos /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
1156*fd82c4c4Schristos    <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
1157*fd82c4c4Schristos    which sometimes causes an unwanted diagnostic for fwrite calls.
1158*fd82c4c4Schristos    This affects only function declaration attributes under certain
1159*fd82c4c4Schristos    versions of gcc and clang, and is not needed for C++.  */
1160*fd82c4c4Schristos #  if (0 < __USE_FORTIFY_LEVEL                                          \
1161*fd82c4c4Schristos        && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
1162*fd82c4c4Schristos        && 3 < __GNUC__ + (4 <= __GNUC_MINOR__)                          \
1163*fd82c4c4Schristos        && !defined __cplusplus)
1164*fd82c4c4Schristos #   undef fwrite
1165*fd82c4c4Schristos #   undef fwrite_unlocked
1166*fd82c4c4Schristos extern size_t __REDIRECT (rpl_fwrite,
1167*fd82c4c4Schristos                           (const void *__restrict, size_t, size_t,
1168*fd82c4c4Schristos                            FILE *__restrict),
1169*fd82c4c4Schristos                           fwrite);
1170*fd82c4c4Schristos extern size_t __REDIRECT (rpl_fwrite_unlocked,
1171*fd82c4c4Schristos                           (const void *__restrict, size_t, size_t,
1172*fd82c4c4Schristos                            FILE *__restrict),
1173*fd82c4c4Schristos                           fwrite_unlocked);
1174*fd82c4c4Schristos #   define fwrite rpl_fwrite
1175*fd82c4c4Schristos #   define fwrite_unlocked rpl_fwrite_unlocked
1176*fd82c4c4Schristos #  endif
1177*fd82c4c4Schristos # endif
1178*fd82c4c4Schristos # if __GLIBC__ >= 2
1179*fd82c4c4Schristos _GL_CXXALIASWARN (fwrite);
1180*fd82c4c4Schristos # endif
1181*fd82c4c4Schristos #endif
1182*fd82c4c4Schristos 
1183*fd82c4c4Schristos #if 1
1184*fd82c4c4Schristos # if 0 && 0
1185*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1186*fd82c4c4Schristos #   undef getc
1187*fd82c4c4Schristos #   define getc rpl_fgetc
1188*fd82c4c4Schristos #  endif
1189*fd82c4c4Schristos _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
1190*fd82c4c4Schristos _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
1191*fd82c4c4Schristos # else
1192*fd82c4c4Schristos _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
1193*fd82c4c4Schristos # endif
1194*fd82c4c4Schristos # if __GLIBC__ >= 2
1195*fd82c4c4Schristos _GL_CXXALIASWARN (getc);
1196*fd82c4c4Schristos # endif
1197*fd82c4c4Schristos #endif
1198*fd82c4c4Schristos 
1199*fd82c4c4Schristos #if 1
1200*fd82c4c4Schristos # if 0 && 0
1201*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1202*fd82c4c4Schristos #   undef getchar
1203*fd82c4c4Schristos #   define getchar rpl_getchar
1204*fd82c4c4Schristos #  endif
1205*fd82c4c4Schristos _GL_FUNCDECL_RPL (getchar, int, (void));
1206*fd82c4c4Schristos _GL_CXXALIAS_RPL (getchar, int, (void));
1207*fd82c4c4Schristos # else
1208*fd82c4c4Schristos _GL_CXXALIAS_SYS (getchar, int, (void));
1209*fd82c4c4Schristos # endif
1210*fd82c4c4Schristos # if __GLIBC__ >= 2
1211*fd82c4c4Schristos _GL_CXXALIASWARN (getchar);
1212*fd82c4c4Schristos # endif
1213*fd82c4c4Schristos #endif
1214*fd82c4c4Schristos 
1215*fd82c4c4Schristos #if 0
1216*fd82c4c4Schristos /* Read input, up to (and including) the next occurrence of DELIMITER, from
1217*fd82c4c4Schristos    STREAM, store it in *LINEPTR (and NUL-terminate it).
1218*fd82c4c4Schristos    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
1219*fd82c4c4Schristos    bytes of space.  It is realloc'd as necessary.
1220*fd82c4c4Schristos    Return the number of bytes read and stored at *LINEPTR (not including the
1221*fd82c4c4Schristos    NUL terminator), or -1 on error or EOF.  */
1222*fd82c4c4Schristos # if 0
1223*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1224*fd82c4c4Schristos #   undef getdelim
1225*fd82c4c4Schristos #   define getdelim rpl_getdelim
1226*fd82c4c4Schristos #  endif
1227*fd82c4c4Schristos _GL_FUNCDECL_RPL (getdelim, ssize_t,
1228*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1229*fd82c4c4Schristos                    int delimiter,
1230*fd82c4c4Schristos                    FILE *restrict stream)
1231*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2, 4)));
1232*fd82c4c4Schristos _GL_CXXALIAS_RPL (getdelim, ssize_t,
1233*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1234*fd82c4c4Schristos                    int delimiter,
1235*fd82c4c4Schristos                    FILE *restrict stream));
1236*fd82c4c4Schristos # else
1237*fd82c4c4Schristos #  if !1
1238*fd82c4c4Schristos _GL_FUNCDECL_SYS (getdelim, ssize_t,
1239*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1240*fd82c4c4Schristos                    int delimiter,
1241*fd82c4c4Schristos                    FILE *restrict stream)
1242*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2, 4)));
1243*fd82c4c4Schristos #  endif
1244*fd82c4c4Schristos _GL_CXXALIAS_SYS (getdelim, ssize_t,
1245*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1246*fd82c4c4Schristos                    int delimiter,
1247*fd82c4c4Schristos                    FILE *restrict stream));
1248*fd82c4c4Schristos # endif
1249*fd82c4c4Schristos _GL_CXXALIASWARN (getdelim);
1250*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1251*fd82c4c4Schristos # undef getdelim
1252*fd82c4c4Schristos # if HAVE_RAW_DECL_GETDELIM
1253*fd82c4c4Schristos _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
1254*fd82c4c4Schristos                  "use gnulib module getdelim for portability");
1255*fd82c4c4Schristos # endif
1256*fd82c4c4Schristos #endif
1257*fd82c4c4Schristos 
1258*fd82c4c4Schristos #if 0
1259*fd82c4c4Schristos /* Read a line, up to (and including) the next newline, from STREAM, store it
1260*fd82c4c4Schristos    in *LINEPTR (and NUL-terminate it).
1261*fd82c4c4Schristos    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
1262*fd82c4c4Schristos    bytes of space.  It is realloc'd as necessary.
1263*fd82c4c4Schristos    Return the number of bytes read and stored at *LINEPTR (not including the
1264*fd82c4c4Schristos    NUL terminator), or -1 on error or EOF.  */
1265*fd82c4c4Schristos # if 0
1266*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1267*fd82c4c4Schristos #   undef getline
1268*fd82c4c4Schristos #   define getline rpl_getline
1269*fd82c4c4Schristos #  endif
1270*fd82c4c4Schristos _GL_FUNCDECL_RPL (getline, ssize_t,
1271*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1272*fd82c4c4Schristos                    FILE *restrict stream)
1273*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2, 3)));
1274*fd82c4c4Schristos _GL_CXXALIAS_RPL (getline, ssize_t,
1275*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1276*fd82c4c4Schristos                    FILE *restrict stream));
1277*fd82c4c4Schristos # else
1278*fd82c4c4Schristos #  if !1
1279*fd82c4c4Schristos _GL_FUNCDECL_SYS (getline, ssize_t,
1280*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1281*fd82c4c4Schristos                    FILE *restrict stream)
1282*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2, 3)));
1283*fd82c4c4Schristos #  endif
1284*fd82c4c4Schristos _GL_CXXALIAS_SYS (getline, ssize_t,
1285*fd82c4c4Schristos                   (char **restrict lineptr, size_t *restrict linesize,
1286*fd82c4c4Schristos                    FILE *restrict stream));
1287*fd82c4c4Schristos # endif
1288*fd82c4c4Schristos # if 1
1289*fd82c4c4Schristos _GL_CXXALIASWARN (getline);
1290*fd82c4c4Schristos # endif
1291*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1292*fd82c4c4Schristos # undef getline
1293*fd82c4c4Schristos # if HAVE_RAW_DECL_GETLINE
1294*fd82c4c4Schristos _GL_WARN_ON_USE (getline, "getline is unportable - "
1295*fd82c4c4Schristos                  "use gnulib module getline for portability");
1296*fd82c4c4Schristos # endif
1297*fd82c4c4Schristos #endif
1298*fd82c4c4Schristos 
1299*fd82c4c4Schristos /* It is very rare that the developer ever has full control of stdin,
1300*fd82c4c4Schristos    so any use of gets warrants an unconditional warning; besides, C11
1301*fd82c4c4Schristos    removed it.  */
1302*fd82c4c4Schristos #undef gets
1303*fd82c4c4Schristos #if HAVE_RAW_DECL_GETS && !defined __cplusplus
1304*fd82c4c4Schristos _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
1305*fd82c4c4Schristos #endif
1306*fd82c4c4Schristos 
1307*fd82c4c4Schristos #if 0 || 0
1308*fd82c4c4Schristos struct obstack;
1309*fd82c4c4Schristos /* Grow an obstack with formatted output.  Return the number of
1310*fd82c4c4Schristos    bytes added to OBS.  No trailing nul byte is added, and the
1311*fd82c4c4Schristos    object should be closed with obstack_finish before use.  Upon
1312*fd82c4c4Schristos    memory allocation error, call obstack_alloc_failed_handler.  Upon
1313*fd82c4c4Schristos    other error, return -1.  */
1314*fd82c4c4Schristos # if 0
1315*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1316*fd82c4c4Schristos #   define obstack_printf rpl_obstack_printf
1317*fd82c4c4Schristos #  endif
1318*fd82c4c4Schristos _GL_FUNCDECL_RPL (obstack_printf, int,
1319*fd82c4c4Schristos                   (struct obstack *obs, const char *format, ...)
1320*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1321*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1322*fd82c4c4Schristos _GL_CXXALIAS_RPL (obstack_printf, int,
1323*fd82c4c4Schristos                   (struct obstack *obs, const char *format, ...));
1324*fd82c4c4Schristos # else
1325*fd82c4c4Schristos #  if !1
1326*fd82c4c4Schristos _GL_FUNCDECL_SYS (obstack_printf, int,
1327*fd82c4c4Schristos                   (struct obstack *obs, const char *format, ...)
1328*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1329*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1330*fd82c4c4Schristos #  endif
1331*fd82c4c4Schristos _GL_CXXALIAS_SYS (obstack_printf, int,
1332*fd82c4c4Schristos                   (struct obstack *obs, const char *format, ...));
1333*fd82c4c4Schristos # endif
1334*fd82c4c4Schristos _GL_CXXALIASWARN (obstack_printf);
1335*fd82c4c4Schristos # if 0
1336*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1337*fd82c4c4Schristos #   define obstack_vprintf rpl_obstack_vprintf
1338*fd82c4c4Schristos #  endif
1339*fd82c4c4Schristos _GL_FUNCDECL_RPL (obstack_vprintf, int,
1340*fd82c4c4Schristos                   (struct obstack *obs, const char *format, va_list args)
1341*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1342*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1343*fd82c4c4Schristos _GL_CXXALIAS_RPL (obstack_vprintf, int,
1344*fd82c4c4Schristos                   (struct obstack *obs, const char *format, va_list args));
1345*fd82c4c4Schristos # else
1346*fd82c4c4Schristos #  if !1
1347*fd82c4c4Schristos _GL_FUNCDECL_SYS (obstack_vprintf, int,
1348*fd82c4c4Schristos                   (struct obstack *obs, const char *format, va_list args)
1349*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1350*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1351*fd82c4c4Schristos #  endif
1352*fd82c4c4Schristos _GL_CXXALIAS_SYS (obstack_vprintf, int,
1353*fd82c4c4Schristos                   (struct obstack *obs, const char *format, va_list args));
1354*fd82c4c4Schristos # endif
1355*fd82c4c4Schristos _GL_CXXALIASWARN (obstack_vprintf);
1356*fd82c4c4Schristos #endif
1357*fd82c4c4Schristos 
1358*fd82c4c4Schristos #if 0
1359*fd82c4c4Schristos # if !1
1360*fd82c4c4Schristos _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
1361*fd82c4c4Schristos # endif
1362*fd82c4c4Schristos _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
1363*fd82c4c4Schristos _GL_CXXALIASWARN (pclose);
1364*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1365*fd82c4c4Schristos # undef pclose
1366*fd82c4c4Schristos # if HAVE_RAW_DECL_PCLOSE
1367*fd82c4c4Schristos _GL_WARN_ON_USE (pclose, "pclose is unportable - "
1368*fd82c4c4Schristos                  "use gnulib module pclose for more portability");
1369*fd82c4c4Schristos # endif
1370*fd82c4c4Schristos #endif
1371*fd82c4c4Schristos 
1372*fd82c4c4Schristos #if 0
1373*fd82c4c4Schristos /* Print a message to standard error, describing the value of ERRNO,
1374*fd82c4c4Schristos    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
1375*fd82c4c4Schristos    and terminated with a newline.  */
1376*fd82c4c4Schristos # if 0
1377*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1378*fd82c4c4Schristos #   define perror rpl_perror
1379*fd82c4c4Schristos #  endif
1380*fd82c4c4Schristos _GL_FUNCDECL_RPL (perror, void, (const char *string));
1381*fd82c4c4Schristos _GL_CXXALIAS_RPL (perror, void, (const char *string));
1382*fd82c4c4Schristos # else
1383*fd82c4c4Schristos _GL_CXXALIAS_SYS (perror, void, (const char *string));
1384*fd82c4c4Schristos # endif
1385*fd82c4c4Schristos # if __GLIBC__ >= 2
1386*fd82c4c4Schristos _GL_CXXALIASWARN (perror);
1387*fd82c4c4Schristos # endif
1388*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1389*fd82c4c4Schristos # undef perror
1390*fd82c4c4Schristos /* Assume perror is always declared.  */
1391*fd82c4c4Schristos _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1392*fd82c4c4Schristos                  "use gnulib module perror for portability");
1393*fd82c4c4Schristos #endif
1394*fd82c4c4Schristos 
1395*fd82c4c4Schristos #if 0
1396*fd82c4c4Schristos # if 0
1397*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1398*fd82c4c4Schristos #   undef popen
1399*fd82c4c4Schristos #   define popen rpl_popen
1400*fd82c4c4Schristos #  endif
1401*fd82c4c4Schristos _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
1402*fd82c4c4Schristos                                  _GL_ARG_NONNULL ((1, 2)));
1403*fd82c4c4Schristos _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
1404*fd82c4c4Schristos # else
1405*fd82c4c4Schristos #  if !1
1406*fd82c4c4Schristos _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
1407*fd82c4c4Schristos                                  _GL_ARG_NONNULL ((1, 2)));
1408*fd82c4c4Schristos #  endif
1409*fd82c4c4Schristos _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
1410*fd82c4c4Schristos # endif
1411*fd82c4c4Schristos _GL_CXXALIASWARN (popen);
1412*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1413*fd82c4c4Schristos # undef popen
1414*fd82c4c4Schristos # if HAVE_RAW_DECL_POPEN
1415*fd82c4c4Schristos _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1416*fd82c4c4Schristos                  "use gnulib module popen or pipe for more portability");
1417*fd82c4c4Schristos # endif
1418*fd82c4c4Schristos #endif
1419*fd82c4c4Schristos 
1420*fd82c4c4Schristos #if 0 || 1
1421*fd82c4c4Schristos # if (0 && 0) \
1422*fd82c4c4Schristos      || (1 && 0 && (0 || 0))
1423*fd82c4c4Schristos #  if defined __GNUC__
1424*fd82c4c4Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1425*fd82c4c4Schristos /* Don't break __attribute__((format(printf,M,N))).  */
1426*fd82c4c4Schristos #    define printf __printf__
1427*fd82c4c4Schristos #   endif
1428*fd82c4c4Schristos #   if 0 || 0
1429*fd82c4c4Schristos _GL_FUNCDECL_RPL_1 (__printf__, int,
1430*fd82c4c4Schristos                     (const char *restrict format, ...)
1431*fd82c4c4Schristos                     __asm__ (
1432*fd82c4c4Schristos                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
1433*fd82c4c4Schristos                     _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
1434*fd82c4c4Schristos                     _GL_ARG_NONNULL ((1)));
1435*fd82c4c4Schristos #   else
1436*fd82c4c4Schristos _GL_FUNCDECL_RPL_1 (__printf__, int,
1437*fd82c4c4Schristos                     (const char *restrict format, ...)
1438*fd82c4c4Schristos                     __asm__ (
1439*fd82c4c4Schristos                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
1440*fd82c4c4Schristos                     _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
1441*fd82c4c4Schristos                     _GL_ARG_NONNULL ((1)));
1442*fd82c4c4Schristos #   endif
1443*fd82c4c4Schristos _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
1444*fd82c4c4Schristos #  else
1445*fd82c4c4Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1446*fd82c4c4Schristos #    define printf rpl_printf
1447*fd82c4c4Schristos #   endif
1448*fd82c4c4Schristos _GL_FUNCDECL_RPL (printf, int,
1449*fd82c4c4Schristos                   (const char *restrict format, ...)
1450*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
1451*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1)));
1452*fd82c4c4Schristos _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
1453*fd82c4c4Schristos #  endif
1454*fd82c4c4Schristos #  define GNULIB_overrides_printf 1
1455*fd82c4c4Schristos # else
1456*fd82c4c4Schristos _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
1457*fd82c4c4Schristos # endif
1458*fd82c4c4Schristos # if __GLIBC__ >= 2
1459*fd82c4c4Schristos _GL_CXXALIASWARN (printf);
1460*fd82c4c4Schristos # endif
1461*fd82c4c4Schristos #endif
1462*fd82c4c4Schristos #if !0 && defined GNULIB_POSIXCHECK
1463*fd82c4c4Schristos # if !GNULIB_overrides_printf
1464*fd82c4c4Schristos #  undef printf
1465*fd82c4c4Schristos # endif
1466*fd82c4c4Schristos /* Assume printf is always declared.  */
1467*fd82c4c4Schristos _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1468*fd82c4c4Schristos                  "use gnulib module printf-posix for portable "
1469*fd82c4c4Schristos                  "POSIX compliance");
1470*fd82c4c4Schristos #endif
1471*fd82c4c4Schristos 
1472*fd82c4c4Schristos #if 1
1473*fd82c4c4Schristos # if 0 && (0 || 0)
1474*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1475*fd82c4c4Schristos #   undef putc
1476*fd82c4c4Schristos #   define putc rpl_fputc
1477*fd82c4c4Schristos #  endif
1478*fd82c4c4Schristos _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
1479*fd82c4c4Schristos _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
1480*fd82c4c4Schristos # else
1481*fd82c4c4Schristos _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
1482*fd82c4c4Schristos # endif
1483*fd82c4c4Schristos # if __GLIBC__ >= 2
1484*fd82c4c4Schristos _GL_CXXALIASWARN (putc);
1485*fd82c4c4Schristos # endif
1486*fd82c4c4Schristos #endif
1487*fd82c4c4Schristos 
1488*fd82c4c4Schristos #if 1
1489*fd82c4c4Schristos # if 0 && (0 || 0)
1490*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1491*fd82c4c4Schristos #   undef putchar
1492*fd82c4c4Schristos #   define putchar rpl_putchar
1493*fd82c4c4Schristos #  endif
1494*fd82c4c4Schristos _GL_FUNCDECL_RPL (putchar, int, (int c));
1495*fd82c4c4Schristos _GL_CXXALIAS_RPL (putchar, int, (int c));
1496*fd82c4c4Schristos # else
1497*fd82c4c4Schristos _GL_CXXALIAS_SYS (putchar, int, (int c));
1498*fd82c4c4Schristos # endif
1499*fd82c4c4Schristos # if __GLIBC__ >= 2
1500*fd82c4c4Schristos _GL_CXXALIASWARN (putchar);
1501*fd82c4c4Schristos # endif
1502*fd82c4c4Schristos #endif
1503*fd82c4c4Schristos 
1504*fd82c4c4Schristos #if 1
1505*fd82c4c4Schristos # if 0 && (0 || 0)
1506*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1507*fd82c4c4Schristos #   undef puts
1508*fd82c4c4Schristos #   define puts rpl_puts
1509*fd82c4c4Schristos #  endif
1510*fd82c4c4Schristos _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
1511*fd82c4c4Schristos _GL_CXXALIAS_RPL (puts, int, (const char *string));
1512*fd82c4c4Schristos # else
1513*fd82c4c4Schristos _GL_CXXALIAS_SYS (puts, int, (const char *string));
1514*fd82c4c4Schristos # endif
1515*fd82c4c4Schristos # if __GLIBC__ >= 2
1516*fd82c4c4Schristos _GL_CXXALIASWARN (puts);
1517*fd82c4c4Schristos # endif
1518*fd82c4c4Schristos #endif
1519*fd82c4c4Schristos 
1520*fd82c4c4Schristos #if 0
1521*fd82c4c4Schristos # if 0
1522*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1523*fd82c4c4Schristos #   undef remove
1524*fd82c4c4Schristos #   define remove rpl_remove
1525*fd82c4c4Schristos #  endif
1526*fd82c4c4Schristos _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
1527*fd82c4c4Schristos _GL_CXXALIAS_RPL (remove, int, (const char *name));
1528*fd82c4c4Schristos # else
1529*fd82c4c4Schristos _GL_CXXALIAS_SYS (remove, int, (const char *name));
1530*fd82c4c4Schristos # endif
1531*fd82c4c4Schristos # if __GLIBC__ >= 2
1532*fd82c4c4Schristos _GL_CXXALIASWARN (remove);
1533*fd82c4c4Schristos # endif
1534*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1535*fd82c4c4Schristos # undef remove
1536*fd82c4c4Schristos /* Assume remove is always declared.  */
1537*fd82c4c4Schristos _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
1538*fd82c4c4Schristos                  "use gnulib module remove for more portability");
1539*fd82c4c4Schristos #endif
1540*fd82c4c4Schristos 
1541*fd82c4c4Schristos #if 1
1542*fd82c4c4Schristos # if 0
1543*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1544*fd82c4c4Schristos #   undef rename
1545*fd82c4c4Schristos #   define rename rpl_rename
1546*fd82c4c4Schristos #  endif
1547*fd82c4c4Schristos _GL_FUNCDECL_RPL (rename, int,
1548*fd82c4c4Schristos                   (const char *old_filename, const char *new_filename)
1549*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1550*fd82c4c4Schristos _GL_CXXALIAS_RPL (rename, int,
1551*fd82c4c4Schristos                   (const char *old_filename, const char *new_filename));
1552*fd82c4c4Schristos # else
1553*fd82c4c4Schristos _GL_CXXALIAS_SYS (rename, int,
1554*fd82c4c4Schristos                   (const char *old_filename, const char *new_filename));
1555*fd82c4c4Schristos # endif
1556*fd82c4c4Schristos # if __GLIBC__ >= 2
1557*fd82c4c4Schristos _GL_CXXALIASWARN (rename);
1558*fd82c4c4Schristos # endif
1559*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1560*fd82c4c4Schristos # undef rename
1561*fd82c4c4Schristos /* Assume rename is always declared.  */
1562*fd82c4c4Schristos _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
1563*fd82c4c4Schristos                  "use gnulib module rename for more portability");
1564*fd82c4c4Schristos #endif
1565*fd82c4c4Schristos 
1566*fd82c4c4Schristos #if 0
1567*fd82c4c4Schristos # if 0
1568*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1569*fd82c4c4Schristos #   undef renameat
1570*fd82c4c4Schristos #   define renameat rpl_renameat
1571*fd82c4c4Schristos #  endif
1572*fd82c4c4Schristos _GL_FUNCDECL_RPL (renameat, int,
1573*fd82c4c4Schristos                   (int fd1, char const *file1, int fd2, char const *file2)
1574*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2, 4)));
1575*fd82c4c4Schristos _GL_CXXALIAS_RPL (renameat, int,
1576*fd82c4c4Schristos                   (int fd1, char const *file1, int fd2, char const *file2));
1577*fd82c4c4Schristos # else
1578*fd82c4c4Schristos #  if !1
1579*fd82c4c4Schristos _GL_FUNCDECL_SYS (renameat, int,
1580*fd82c4c4Schristos                   (int fd1, char const *file1, int fd2, char const *file2)
1581*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2, 4)));
1582*fd82c4c4Schristos #  endif
1583*fd82c4c4Schristos _GL_CXXALIAS_SYS (renameat, int,
1584*fd82c4c4Schristos                   (int fd1, char const *file1, int fd2, char const *file2));
1585*fd82c4c4Schristos # endif
1586*fd82c4c4Schristos _GL_CXXALIASWARN (renameat);
1587*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1588*fd82c4c4Schristos # undef renameat
1589*fd82c4c4Schristos # if HAVE_RAW_DECL_RENAMEAT
1590*fd82c4c4Schristos _GL_WARN_ON_USE (renameat, "renameat is not portable - "
1591*fd82c4c4Schristos                  "use gnulib module renameat for portability");
1592*fd82c4c4Schristos # endif
1593*fd82c4c4Schristos #endif
1594*fd82c4c4Schristos 
1595*fd82c4c4Schristos #if 1
1596*fd82c4c4Schristos # if 0 && 0
1597*fd82c4c4Schristos #  if defined __GNUC__
1598*fd82c4c4Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1599*fd82c4c4Schristos #    undef scanf
1600*fd82c4c4Schristos /* Don't break __attribute__((format(scanf,M,N))).  */
1601*fd82c4c4Schristos #    define scanf __scanf__
1602*fd82c4c4Schristos #   endif
1603*fd82c4c4Schristos _GL_FUNCDECL_RPL_1 (__scanf__, int,
1604*fd82c4c4Schristos                     (const char *restrict format, ...)
1605*fd82c4c4Schristos                     __asm__ (
1606*fd82c4c4Schristos                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
1607*fd82c4c4Schristos                     _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1608*fd82c4c4Schristos                     _GL_ARG_NONNULL ((1)));
1609*fd82c4c4Schristos _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
1610*fd82c4c4Schristos #  else
1611*fd82c4c4Schristos #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1612*fd82c4c4Schristos #    undef scanf
1613*fd82c4c4Schristos #    define scanf rpl_scanf
1614*fd82c4c4Schristos #   endif
1615*fd82c4c4Schristos _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
1616*fd82c4c4Schristos                               _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1617*fd82c4c4Schristos                               _GL_ARG_NONNULL ((1)));
1618*fd82c4c4Schristos _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
1619*fd82c4c4Schristos #  endif
1620*fd82c4c4Schristos # else
1621*fd82c4c4Schristos _GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
1622*fd82c4c4Schristos # endif
1623*fd82c4c4Schristos # if __GLIBC__ >= 2
1624*fd82c4c4Schristos _GL_CXXALIASWARN (scanf);
1625*fd82c4c4Schristos # endif
1626*fd82c4c4Schristos #endif
1627*fd82c4c4Schristos 
1628*fd82c4c4Schristos #if 0
1629*fd82c4c4Schristos # if 0
1630*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1631*fd82c4c4Schristos #   define snprintf rpl_snprintf
1632*fd82c4c4Schristos #  endif
1633*fd82c4c4Schristos _GL_FUNCDECL_RPL (snprintf, int,
1634*fd82c4c4Schristos                   (char *restrict str, size_t size,
1635*fd82c4c4Schristos                    const char *restrict format, ...)
1636*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
1637*fd82c4c4Schristos                   _GL_ARG_NONNULL ((3)));
1638*fd82c4c4Schristos _GL_CXXALIAS_RPL (snprintf, int,
1639*fd82c4c4Schristos                   (char *restrict str, size_t size,
1640*fd82c4c4Schristos                    const char *restrict format, ...));
1641*fd82c4c4Schristos # else
1642*fd82c4c4Schristos #  if !1
1643*fd82c4c4Schristos _GL_FUNCDECL_SYS (snprintf, int,
1644*fd82c4c4Schristos                   (char *restrict str, size_t size,
1645*fd82c4c4Schristos                    const char *restrict format, ...)
1646*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
1647*fd82c4c4Schristos                   _GL_ARG_NONNULL ((3)));
1648*fd82c4c4Schristos #  endif
1649*fd82c4c4Schristos _GL_CXXALIAS_SYS (snprintf, int,
1650*fd82c4c4Schristos                   (char *restrict str, size_t size,
1651*fd82c4c4Schristos                    const char *restrict format, ...));
1652*fd82c4c4Schristos # endif
1653*fd82c4c4Schristos _GL_CXXALIASWARN (snprintf);
1654*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1655*fd82c4c4Schristos # undef snprintf
1656*fd82c4c4Schristos # if HAVE_RAW_DECL_SNPRINTF
1657*fd82c4c4Schristos _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1658*fd82c4c4Schristos                  "use gnulib module snprintf for portability");
1659*fd82c4c4Schristos # endif
1660*fd82c4c4Schristos #endif
1661*fd82c4c4Schristos 
1662*fd82c4c4Schristos /* Some people would argue that all sprintf uses should be warned about
1663*fd82c4c4Schristos    (for example, OpenBSD issues a link warning for it),
1664*fd82c4c4Schristos    since it can cause security holes due to buffer overruns.
1665*fd82c4c4Schristos    However, we believe that sprintf can be used safely, and is more
1666*fd82c4c4Schristos    efficient than snprintf in those safe cases; and as proof of our
1667*fd82c4c4Schristos    belief, we use sprintf in several gnulib modules.  So this header
1668*fd82c4c4Schristos    intentionally avoids adding a warning to sprintf except when
1669*fd82c4c4Schristos    GNULIB_POSIXCHECK is defined.  */
1670*fd82c4c4Schristos 
1671*fd82c4c4Schristos #if 0
1672*fd82c4c4Schristos # if 0
1673*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1674*fd82c4c4Schristos #   define sprintf rpl_sprintf
1675*fd82c4c4Schristos #  endif
1676*fd82c4c4Schristos _GL_FUNCDECL_RPL (sprintf, int,
1677*fd82c4c4Schristos                   (char *restrict str, const char *restrict format, ...)
1678*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1679*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1680*fd82c4c4Schristos _GL_CXXALIAS_RPL (sprintf, int,
1681*fd82c4c4Schristos                   (char *restrict str, const char *restrict format, ...));
1682*fd82c4c4Schristos # else
1683*fd82c4c4Schristos _GL_CXXALIAS_SYS (sprintf, int,
1684*fd82c4c4Schristos                   (char *restrict str, const char *restrict format, ...));
1685*fd82c4c4Schristos # endif
1686*fd82c4c4Schristos # if __GLIBC__ >= 2
1687*fd82c4c4Schristos _GL_CXXALIASWARN (sprintf);
1688*fd82c4c4Schristos # endif
1689*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1690*fd82c4c4Schristos # undef sprintf
1691*fd82c4c4Schristos /* Assume sprintf is always declared.  */
1692*fd82c4c4Schristos _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1693*fd82c4c4Schristos                  "use gnulib module sprintf-posix for portable "
1694*fd82c4c4Schristos                  "POSIX compliance");
1695*fd82c4c4Schristos #endif
1696*fd82c4c4Schristos 
1697*fd82c4c4Schristos #if 0
1698*fd82c4c4Schristos # if 0
1699*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1700*fd82c4c4Schristos #   define tmpfile rpl_tmpfile
1701*fd82c4c4Schristos #  endif
1702*fd82c4c4Schristos _GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
1703*fd82c4c4Schristos _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1704*fd82c4c4Schristos # else
1705*fd82c4c4Schristos _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1706*fd82c4c4Schristos # endif
1707*fd82c4c4Schristos # if __GLIBC__ >= 2
1708*fd82c4c4Schristos _GL_CXXALIASWARN (tmpfile);
1709*fd82c4c4Schristos # endif
1710*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1711*fd82c4c4Schristos # undef tmpfile
1712*fd82c4c4Schristos # if HAVE_RAW_DECL_TMPFILE
1713*fd82c4c4Schristos _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1714*fd82c4c4Schristos                  "use gnulib module tmpfile for portability");
1715*fd82c4c4Schristos # endif
1716*fd82c4c4Schristos #endif
1717*fd82c4c4Schristos 
1718*fd82c4c4Schristos #if 0
1719*fd82c4c4Schristos /* Write formatted output to a string dynamically allocated with malloc().
1720*fd82c4c4Schristos    If the memory allocation succeeds, store the address of the string in
1721*fd82c4c4Schristos    *RESULT and return the number of resulting bytes, excluding the trailing
1722*fd82c4c4Schristos    NUL.  Upon memory allocation error, or some other error, return -1.  */
1723*fd82c4c4Schristos # if 0
1724*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1725*fd82c4c4Schristos #   define asprintf rpl_asprintf
1726*fd82c4c4Schristos #  endif
1727*fd82c4c4Schristos _GL_FUNCDECL_RPL (asprintf, int,
1728*fd82c4c4Schristos                   (char **result, const char *format, ...)
1729*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1730*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1731*fd82c4c4Schristos _GL_CXXALIAS_RPL (asprintf, int,
1732*fd82c4c4Schristos                   (char **result, const char *format, ...));
1733*fd82c4c4Schristos # else
1734*fd82c4c4Schristos #  if !1
1735*fd82c4c4Schristos _GL_FUNCDECL_SYS (asprintf, int,
1736*fd82c4c4Schristos                   (char **result, const char *format, ...)
1737*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1738*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1739*fd82c4c4Schristos #  endif
1740*fd82c4c4Schristos _GL_CXXALIAS_SYS (asprintf, int,
1741*fd82c4c4Schristos                   (char **result, const char *format, ...));
1742*fd82c4c4Schristos # endif
1743*fd82c4c4Schristos _GL_CXXALIASWARN (asprintf);
1744*fd82c4c4Schristos # if 0
1745*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1746*fd82c4c4Schristos #   define vasprintf rpl_vasprintf
1747*fd82c4c4Schristos #  endif
1748*fd82c4c4Schristos _GL_FUNCDECL_RPL (vasprintf, int,
1749*fd82c4c4Schristos                   (char **result, const char *format, va_list args)
1750*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1751*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1752*fd82c4c4Schristos _GL_CXXALIAS_RPL (vasprintf, int,
1753*fd82c4c4Schristos                   (char **result, const char *format, va_list args));
1754*fd82c4c4Schristos # else
1755*fd82c4c4Schristos #  if !1
1756*fd82c4c4Schristos _GL_FUNCDECL_SYS (vasprintf, int,
1757*fd82c4c4Schristos                   (char **result, const char *format, va_list args)
1758*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1759*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1760*fd82c4c4Schristos #  endif
1761*fd82c4c4Schristos _GL_CXXALIAS_SYS (vasprintf, int,
1762*fd82c4c4Schristos                   (char **result, const char *format, va_list args));
1763*fd82c4c4Schristos # endif
1764*fd82c4c4Schristos _GL_CXXALIASWARN (vasprintf);
1765*fd82c4c4Schristos #endif
1766*fd82c4c4Schristos 
1767*fd82c4c4Schristos #if 0
1768*fd82c4c4Schristos # if 0
1769*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1770*fd82c4c4Schristos #   define vdprintf rpl_vdprintf
1771*fd82c4c4Schristos #  endif
1772*fd82c4c4Schristos _GL_FUNCDECL_RPL (vdprintf, int,
1773*fd82c4c4Schristos                   (int fd, const char *restrict format, va_list args)
1774*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1775*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2)));
1776*fd82c4c4Schristos _GL_CXXALIAS_RPL (vdprintf, int,
1777*fd82c4c4Schristos                   (int fd, const char *restrict format, va_list args));
1778*fd82c4c4Schristos # else
1779*fd82c4c4Schristos #  if !1
1780*fd82c4c4Schristos _GL_FUNCDECL_SYS (vdprintf, int,
1781*fd82c4c4Schristos                   (int fd, const char *restrict format, va_list args)
1782*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1783*fd82c4c4Schristos                   _GL_ARG_NONNULL ((2)));
1784*fd82c4c4Schristos #  endif
1785*fd82c4c4Schristos /* Need to cast, because on Solaris, the third parameter will likely be
1786*fd82c4c4Schristos                                                     __va_list args.  */
1787*fd82c4c4Schristos _GL_CXXALIAS_SYS_CAST (vdprintf, int,
1788*fd82c4c4Schristos                        (int fd, const char *restrict format, va_list args));
1789*fd82c4c4Schristos # endif
1790*fd82c4c4Schristos # if __GLIBC__ >= 2
1791*fd82c4c4Schristos _GL_CXXALIASWARN (vdprintf);
1792*fd82c4c4Schristos # endif
1793*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1794*fd82c4c4Schristos # undef vdprintf
1795*fd82c4c4Schristos # if HAVE_RAW_DECL_VDPRINTF
1796*fd82c4c4Schristos _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1797*fd82c4c4Schristos                  "use gnulib module vdprintf for portability");
1798*fd82c4c4Schristos # endif
1799*fd82c4c4Schristos #endif
1800*fd82c4c4Schristos 
1801*fd82c4c4Schristos #if 0 || 1
1802*fd82c4c4Schristos # if (0 && 0) \
1803*fd82c4c4Schristos      || (1 && 0 && (0 || 0))
1804*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1805*fd82c4c4Schristos #   define vfprintf rpl_vfprintf
1806*fd82c4c4Schristos #  endif
1807*fd82c4c4Schristos #  define GNULIB_overrides_vfprintf 1
1808*fd82c4c4Schristos #  if 0
1809*fd82c4c4Schristos _GL_FUNCDECL_RPL (vfprintf, int,
1810*fd82c4c4Schristos                   (FILE *restrict fp,
1811*fd82c4c4Schristos                    const char *restrict format, va_list args)
1812*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1813*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1814*fd82c4c4Schristos #  else
1815*fd82c4c4Schristos _GL_FUNCDECL_RPL (vfprintf, int,
1816*fd82c4c4Schristos                   (FILE *restrict fp,
1817*fd82c4c4Schristos                    const char *restrict format, va_list args)
1818*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1819*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1820*fd82c4c4Schristos #  endif
1821*fd82c4c4Schristos _GL_CXXALIAS_RPL (vfprintf, int,
1822*fd82c4c4Schristos                   (FILE *restrict fp,
1823*fd82c4c4Schristos                    const char *restrict format, va_list args));
1824*fd82c4c4Schristos # else
1825*fd82c4c4Schristos /* Need to cast, because on Solaris, the third parameter is
1826*fd82c4c4Schristos                                                       __va_list args
1827*fd82c4c4Schristos    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1828*fd82c4c4Schristos _GL_CXXALIAS_SYS_CAST (vfprintf, int,
1829*fd82c4c4Schristos                        (FILE *restrict fp,
1830*fd82c4c4Schristos                         const char *restrict format, va_list args));
1831*fd82c4c4Schristos # endif
1832*fd82c4c4Schristos # if __GLIBC__ >= 2
1833*fd82c4c4Schristos _GL_CXXALIASWARN (vfprintf);
1834*fd82c4c4Schristos # endif
1835*fd82c4c4Schristos #endif
1836*fd82c4c4Schristos #if !0 && defined GNULIB_POSIXCHECK
1837*fd82c4c4Schristos # if !GNULIB_overrides_vfprintf
1838*fd82c4c4Schristos #  undef vfprintf
1839*fd82c4c4Schristos # endif
1840*fd82c4c4Schristos /* Assume vfprintf is always declared.  */
1841*fd82c4c4Schristos _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1842*fd82c4c4Schristos                  "use gnulib module vfprintf-posix for portable "
1843*fd82c4c4Schristos                       "POSIX compliance");
1844*fd82c4c4Schristos #endif
1845*fd82c4c4Schristos 
1846*fd82c4c4Schristos #if 0
1847*fd82c4c4Schristos # if 0 && 0
1848*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1849*fd82c4c4Schristos #   undef vfscanf
1850*fd82c4c4Schristos #   define vfscanf rpl_vfscanf
1851*fd82c4c4Schristos #  endif
1852*fd82c4c4Schristos _GL_FUNCDECL_RPL (vfscanf, int,
1853*fd82c4c4Schristos                   (FILE *restrict stream,
1854*fd82c4c4Schristos                    const char *restrict format, va_list args)
1855*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1856*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1857*fd82c4c4Schristos _GL_CXXALIAS_RPL (vfscanf, int,
1858*fd82c4c4Schristos                   (FILE *restrict stream,
1859*fd82c4c4Schristos                    const char *restrict format, va_list args));
1860*fd82c4c4Schristos # else
1861*fd82c4c4Schristos _GL_CXXALIAS_SYS (vfscanf, int,
1862*fd82c4c4Schristos                   (FILE *restrict stream,
1863*fd82c4c4Schristos                    const char *restrict format, va_list args));
1864*fd82c4c4Schristos # endif
1865*fd82c4c4Schristos _GL_CXXALIASWARN (vfscanf);
1866*fd82c4c4Schristos #endif
1867*fd82c4c4Schristos 
1868*fd82c4c4Schristos #if 0 || 1
1869*fd82c4c4Schristos # if (0 && 0) \
1870*fd82c4c4Schristos      || (1 && 0 && (0 || 0))
1871*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1872*fd82c4c4Schristos #   define vprintf rpl_vprintf
1873*fd82c4c4Schristos #  endif
1874*fd82c4c4Schristos #  define GNULIB_overrides_vprintf 1
1875*fd82c4c4Schristos #  if 0 || 0
1876*fd82c4c4Schristos _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1877*fd82c4c4Schristos                                 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
1878*fd82c4c4Schristos                                 _GL_ARG_NONNULL ((1)));
1879*fd82c4c4Schristos #  else
1880*fd82c4c4Schristos _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1881*fd82c4c4Schristos                                 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1882*fd82c4c4Schristos                                 _GL_ARG_NONNULL ((1)));
1883*fd82c4c4Schristos #  endif
1884*fd82c4c4Schristos _GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
1885*fd82c4c4Schristos # else
1886*fd82c4c4Schristos /* Need to cast, because on Solaris, the second parameter is
1887*fd82c4c4Schristos                                                           __va_list args
1888*fd82c4c4Schristos    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1889*fd82c4c4Schristos _GL_CXXALIAS_SYS_CAST (vprintf, int,
1890*fd82c4c4Schristos                        (const char *restrict format, va_list args));
1891*fd82c4c4Schristos # endif
1892*fd82c4c4Schristos # if __GLIBC__ >= 2
1893*fd82c4c4Schristos _GL_CXXALIASWARN (vprintf);
1894*fd82c4c4Schristos # endif
1895*fd82c4c4Schristos #endif
1896*fd82c4c4Schristos #if !0 && defined GNULIB_POSIXCHECK
1897*fd82c4c4Schristos # if !GNULIB_overrides_vprintf
1898*fd82c4c4Schristos #  undef vprintf
1899*fd82c4c4Schristos # endif
1900*fd82c4c4Schristos /* Assume vprintf is always declared.  */
1901*fd82c4c4Schristos _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1902*fd82c4c4Schristos                  "use gnulib module vprintf-posix for portable "
1903*fd82c4c4Schristos                  "POSIX compliance");
1904*fd82c4c4Schristos #endif
1905*fd82c4c4Schristos 
1906*fd82c4c4Schristos #if 0
1907*fd82c4c4Schristos # if 0 && 0
1908*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1909*fd82c4c4Schristos #   undef vscanf
1910*fd82c4c4Schristos #   define vscanf rpl_vscanf
1911*fd82c4c4Schristos #  endif
1912*fd82c4c4Schristos _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
1913*fd82c4c4Schristos                                _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1914*fd82c4c4Schristos                                _GL_ARG_NONNULL ((1)));
1915*fd82c4c4Schristos _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1916*fd82c4c4Schristos # else
1917*fd82c4c4Schristos _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
1918*fd82c4c4Schristos # endif
1919*fd82c4c4Schristos _GL_CXXALIASWARN (vscanf);
1920*fd82c4c4Schristos #endif
1921*fd82c4c4Schristos 
1922*fd82c4c4Schristos #if 0
1923*fd82c4c4Schristos # if 0
1924*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1925*fd82c4c4Schristos #   define vsnprintf rpl_vsnprintf
1926*fd82c4c4Schristos #  endif
1927*fd82c4c4Schristos _GL_FUNCDECL_RPL (vsnprintf, int,
1928*fd82c4c4Schristos                   (char *restrict str, size_t size,
1929*fd82c4c4Schristos                    const char *restrict format, va_list args)
1930*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1931*fd82c4c4Schristos                   _GL_ARG_NONNULL ((3)));
1932*fd82c4c4Schristos _GL_CXXALIAS_RPL (vsnprintf, int,
1933*fd82c4c4Schristos                   (char *restrict str, size_t size,
1934*fd82c4c4Schristos                    const char *restrict format, va_list args));
1935*fd82c4c4Schristos # else
1936*fd82c4c4Schristos #  if !1
1937*fd82c4c4Schristos _GL_FUNCDECL_SYS (vsnprintf, int,
1938*fd82c4c4Schristos                   (char *restrict str, size_t size,
1939*fd82c4c4Schristos                    const char *restrict format, va_list args)
1940*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1941*fd82c4c4Schristos                   _GL_ARG_NONNULL ((3)));
1942*fd82c4c4Schristos #  endif
1943*fd82c4c4Schristos _GL_CXXALIAS_SYS (vsnprintf, int,
1944*fd82c4c4Schristos                   (char *restrict str, size_t size,
1945*fd82c4c4Schristos                    const char *restrict format, va_list args));
1946*fd82c4c4Schristos # endif
1947*fd82c4c4Schristos _GL_CXXALIASWARN (vsnprintf);
1948*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1949*fd82c4c4Schristos # undef vsnprintf
1950*fd82c4c4Schristos # if HAVE_RAW_DECL_VSNPRINTF
1951*fd82c4c4Schristos _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1952*fd82c4c4Schristos                  "use gnulib module vsnprintf for portability");
1953*fd82c4c4Schristos # endif
1954*fd82c4c4Schristos #endif
1955*fd82c4c4Schristos 
1956*fd82c4c4Schristos #if 0
1957*fd82c4c4Schristos # if 0
1958*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1959*fd82c4c4Schristos #   define vsprintf rpl_vsprintf
1960*fd82c4c4Schristos #  endif
1961*fd82c4c4Schristos _GL_FUNCDECL_RPL (vsprintf, int,
1962*fd82c4c4Schristos                   (char *restrict str,
1963*fd82c4c4Schristos                    const char *restrict format, va_list args)
1964*fd82c4c4Schristos                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1965*fd82c4c4Schristos                   _GL_ARG_NONNULL ((1, 2)));
1966*fd82c4c4Schristos _GL_CXXALIAS_RPL (vsprintf, int,
1967*fd82c4c4Schristos                   (char *restrict str,
1968*fd82c4c4Schristos                    const char *restrict format, va_list args));
1969*fd82c4c4Schristos # else
1970*fd82c4c4Schristos /* Need to cast, because on Solaris, the third parameter is
1971*fd82c4c4Schristos                                                        __va_list args
1972*fd82c4c4Schristos    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1973*fd82c4c4Schristos _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1974*fd82c4c4Schristos                        (char *restrict str,
1975*fd82c4c4Schristos                         const char *restrict format, va_list args));
1976*fd82c4c4Schristos # endif
1977*fd82c4c4Schristos # if __GLIBC__ >= 2
1978*fd82c4c4Schristos _GL_CXXALIASWARN (vsprintf);
1979*fd82c4c4Schristos # endif
1980*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
1981*fd82c4c4Schristos # undef vsprintf
1982*fd82c4c4Schristos /* Assume vsprintf is always declared.  */
1983*fd82c4c4Schristos _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1984*fd82c4c4Schristos                  "use gnulib module vsprintf-posix for portable "
1985*fd82c4c4Schristos                       "POSIX compliance");
1986*fd82c4c4Schristos #endif
1987*fd82c4c4Schristos 
1988*fd82c4c4Schristos #endif /* _GL_STDIO_H */
1989*fd82c4c4Schristos #endif /* _GL_STDIO_H */
1990*fd82c4c4Schristos #endif
1991