1*56bb7041Schristos /* This file is automatically generated.  DO NOT EDIT! */
2*56bb7041Schristos /* Generated from: NetBSD: mknative-gdb,v 1.14 2020/09/24 14:53:17 christos Exp  */
3*56bb7041Schristos /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4*56bb7041Schristos 
5*56bb7041Schristos /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6*56bb7041Schristos /* Substitute for and wrapper around <fnmatch.h>.
7*56bb7041Schristos    Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2020 Free
8*56bb7041Schristos    Software Foundation, Inc.
9*56bb7041Schristos 
10*56bb7041Schristos    This file is part of the GNU C Library.
11*56bb7041Schristos 
12*56bb7041Schristos    This program is free software; you can redistribute it and/or modify
13*56bb7041Schristos    it under the terms of the GNU General Public License as published by
14*56bb7041Schristos    the Free Software Foundation; either version 3, or (at your option)
15*56bb7041Schristos    any later version.
16*56bb7041Schristos 
17*56bb7041Schristos    This program is distributed in the hope that it will be useful,
18*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
19*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20*56bb7041Schristos    GNU General Public License for more details.
21*56bb7041Schristos 
22*56bb7041Schristos    You should have received a copy of the GNU General Public License
23*56bb7041Schristos    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
24*56bb7041Schristos 
25*56bb7041Schristos #ifndef _GL_FNMATCH_H
26*56bb7041Schristos 
27*56bb7041Schristos #if __GNUC__ >= 3
28*56bb7041Schristos #pragma GCC system_header
29*56bb7041Schristos #endif
30*56bb7041Schristos 
31*56bb7041Schristos 
32*56bb7041Schristos /* The include_next requires a split double-inclusion guard.  */
33*56bb7041Schristos #if 1 && !1
34*56bb7041Schristos # include_next <fnmatch.h>
35*56bb7041Schristos #endif
36*56bb7041Schristos 
37*56bb7041Schristos #ifndef _GL_FNMATCH_H
38*56bb7041Schristos #define _GL_FNMATCH_H
39*56bb7041Schristos 
40*56bb7041Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
41*56bb7041Schristos /* C++ compatible function declaration macros.
42*56bb7041Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
43*56bb7041Schristos 
44*56bb7041Schristos    This program is free software: you can redistribute it and/or modify it
45*56bb7041Schristos    under the terms of the GNU General Public License as published
46*56bb7041Schristos    by the Free Software Foundation; either version 3 of the License, or
47*56bb7041Schristos    (at your option) any later version.
48*56bb7041Schristos 
49*56bb7041Schristos    This program is distributed in the hope that it will be useful,
50*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
51*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
52*56bb7041Schristos    General Public License for more details.
53*56bb7041Schristos 
54*56bb7041Schristos    You should have received a copy of the GNU General Public License
55*56bb7041Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
56*56bb7041Schristos 
57*56bb7041Schristos #ifndef _GL_CXXDEFS_H
58*56bb7041Schristos #define _GL_CXXDEFS_H
59*56bb7041Schristos 
60*56bb7041Schristos /* Begin/end the GNULIB_NAMESPACE namespace.  */
61*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
62*56bb7041Schristos # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
63*56bb7041Schristos # define _GL_END_NAMESPACE }
64*56bb7041Schristos #else
65*56bb7041Schristos # define _GL_BEGIN_NAMESPACE
66*56bb7041Schristos # define _GL_END_NAMESPACE
67*56bb7041Schristos #endif
68*56bb7041Schristos 
69*56bb7041Schristos /* The three most frequent use cases of these macros are:
70*56bb7041Schristos 
71*56bb7041Schristos    * For providing a substitute for a function that is missing on some
72*56bb7041Schristos      platforms, but is declared and works fine on the platforms on which
73*56bb7041Schristos      it exists:
74*56bb7041Schristos 
75*56bb7041Schristos        #if @GNULIB_FOO@
76*56bb7041Schristos        # if !@HAVE_FOO@
77*56bb7041Schristos        _GL_FUNCDECL_SYS (foo, ...);
78*56bb7041Schristos        # endif
79*56bb7041Schristos        _GL_CXXALIAS_SYS (foo, ...);
80*56bb7041Schristos        _GL_CXXALIASWARN (foo);
81*56bb7041Schristos        #elif defined GNULIB_POSIXCHECK
82*56bb7041Schristos        ...
83*56bb7041Schristos        #endif
84*56bb7041Schristos 
85*56bb7041Schristos    * For providing a replacement for a function that exists on all platforms,
86*56bb7041Schristos      but is broken/insufficient and needs to be replaced on some platforms:
87*56bb7041Schristos 
88*56bb7041Schristos        #if @GNULIB_FOO@
89*56bb7041Schristos        # if @REPLACE_FOO@
90*56bb7041Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
91*56bb7041Schristos        #   undef foo
92*56bb7041Schristos        #   define foo rpl_foo
93*56bb7041Schristos        #  endif
94*56bb7041Schristos        _GL_FUNCDECL_RPL (foo, ...);
95*56bb7041Schristos        _GL_CXXALIAS_RPL (foo, ...);
96*56bb7041Schristos        # else
97*56bb7041Schristos        _GL_CXXALIAS_SYS (foo, ...);
98*56bb7041Schristos        # endif
99*56bb7041Schristos        _GL_CXXALIASWARN (foo);
100*56bb7041Schristos        #elif defined GNULIB_POSIXCHECK
101*56bb7041Schristos        ...
102*56bb7041Schristos        #endif
103*56bb7041Schristos 
104*56bb7041Schristos    * For providing a replacement for a function that exists on some platforms
105*56bb7041Schristos      but is broken/insufficient and needs to be replaced on some of them and
106*56bb7041Schristos      is additionally either missing or undeclared on some other platforms:
107*56bb7041Schristos 
108*56bb7041Schristos        #if @GNULIB_FOO@
109*56bb7041Schristos        # if @REPLACE_FOO@
110*56bb7041Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
111*56bb7041Schristos        #   undef foo
112*56bb7041Schristos        #   define foo rpl_foo
113*56bb7041Schristos        #  endif
114*56bb7041Schristos        _GL_FUNCDECL_RPL (foo, ...);
115*56bb7041Schristos        _GL_CXXALIAS_RPL (foo, ...);
116*56bb7041Schristos        # else
117*56bb7041Schristos        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
118*56bb7041Schristos        _GL_FUNCDECL_SYS (foo, ...);
119*56bb7041Schristos        #  endif
120*56bb7041Schristos        _GL_CXXALIAS_SYS (foo, ...);
121*56bb7041Schristos        # endif
122*56bb7041Schristos        _GL_CXXALIASWARN (foo);
123*56bb7041Schristos        #elif defined GNULIB_POSIXCHECK
124*56bb7041Schristos        ...
125*56bb7041Schristos        #endif
126*56bb7041Schristos */
127*56bb7041Schristos 
128*56bb7041Schristos /* _GL_EXTERN_C declaration;
129*56bb7041Schristos    performs the declaration with C linkage.  */
130*56bb7041Schristos #if defined __cplusplus
131*56bb7041Schristos # define _GL_EXTERN_C extern "C"
132*56bb7041Schristos #else
133*56bb7041Schristos # define _GL_EXTERN_C extern
134*56bb7041Schristos #endif
135*56bb7041Schristos 
136*56bb7041Schristos /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
137*56bb7041Schristos    declares a replacement function, named rpl_func, with the given prototype,
138*56bb7041Schristos    consisting of return type, parameters, and attributes.
139*56bb7041Schristos    Example:
140*56bb7041Schristos      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
141*56bb7041Schristos                                   _GL_ARG_NONNULL ((1)));
142*56bb7041Schristos  */
143*56bb7041Schristos #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
144*56bb7041Schristos   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
145*56bb7041Schristos #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
146*56bb7041Schristos   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
147*56bb7041Schristos 
148*56bb7041Schristos /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
149*56bb7041Schristos    declares the system function, named func, with the given prototype,
150*56bb7041Schristos    consisting of return type, parameters, and attributes.
151*56bb7041Schristos    Example:
152*56bb7041Schristos      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
153*56bb7041Schristos                                   _GL_ARG_NONNULL ((1)));
154*56bb7041Schristos  */
155*56bb7041Schristos #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
156*56bb7041Schristos   _GL_EXTERN_C rettype func parameters_and_attributes
157*56bb7041Schristos 
158*56bb7041Schristos /* _GL_CXXALIAS_RPL (func, rettype, parameters);
159*56bb7041Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
160*56bb7041Schristos    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
161*56bb7041Schristos    Example:
162*56bb7041Schristos      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
163*56bb7041Schristos 
164*56bb7041Schristos    Wrapping rpl_func in an object with an inline conversion operator
165*56bb7041Schristos    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
166*56bb7041Schristos    actually used in the program.  */
167*56bb7041Schristos #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
168*56bb7041Schristos   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
169*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
170*56bb7041Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
171*56bb7041Schristos     namespace GNULIB_NAMESPACE                                \
172*56bb7041Schristos     {                                                         \
173*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper            \
174*56bb7041Schristos       {                                                       \
175*56bb7041Schristos         typedef rettype (*type) parameters;                   \
176*56bb7041Schristos                                                               \
177*56bb7041Schristos         inline operator type () const                         \
178*56bb7041Schristos         {                                                     \
179*56bb7041Schristos           return ::rpl_func;                                  \
180*56bb7041Schristos         }                                                     \
181*56bb7041Schristos       } func = {};                                            \
182*56bb7041Schristos     }                                                         \
183*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
184*56bb7041Schristos #else
185*56bb7041Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
186*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
187*56bb7041Schristos #endif
188*56bb7041Schristos 
189*56bb7041Schristos /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
190*56bb7041Schristos    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
191*56bb7041Schristos    except that the C function rpl_func may have a slightly different
192*56bb7041Schristos    declaration.  A cast is used to silence the "invalid conversion" error
193*56bb7041Schristos    that would otherwise occur.  */
194*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
195*56bb7041Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
196*56bb7041Schristos     namespace GNULIB_NAMESPACE                                     \
197*56bb7041Schristos     {                                                              \
198*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper                 \
199*56bb7041Schristos       {                                                            \
200*56bb7041Schristos         typedef rettype (*type) parameters;                        \
201*56bb7041Schristos                                                                    \
202*56bb7041Schristos         inline operator type () const                              \
203*56bb7041Schristos         {                                                          \
204*56bb7041Schristos           return reinterpret_cast<type>(::rpl_func);               \
205*56bb7041Schristos         }                                                          \
206*56bb7041Schristos       } func = {};                                                 \
207*56bb7041Schristos     }                                                              \
208*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
209*56bb7041Schristos #else
210*56bb7041Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
211*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
212*56bb7041Schristos #endif
213*56bb7041Schristos 
214*56bb7041Schristos /* _GL_CXXALIAS_SYS (func, rettype, parameters);
215*56bb7041Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
216*56bb7041Schristos    that redirects to the system provided function func, if GNULIB_NAMESPACE
217*56bb7041Schristos    is defined.
218*56bb7041Schristos    Example:
219*56bb7041Schristos      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
220*56bb7041Schristos 
221*56bb7041Schristos    Wrapping func in an object with an inline conversion operator
222*56bb7041Schristos    avoids a reference to func unless GNULIB_NAMESPACE::func is
223*56bb7041Schristos    actually used in the program.  */
224*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
225*56bb7041Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
226*56bb7041Schristos     namespace GNULIB_NAMESPACE                                \
227*56bb7041Schristos     {                                                         \
228*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper            \
229*56bb7041Schristos       {                                                       \
230*56bb7041Schristos         typedef rettype (*type) parameters;                   \
231*56bb7041Schristos                                                               \
232*56bb7041Schristos         inline operator type () const                         \
233*56bb7041Schristos         {                                                     \
234*56bb7041Schristos           return ::func;                                      \
235*56bb7041Schristos         }                                                     \
236*56bb7041Schristos       } func = {};                                            \
237*56bb7041Schristos     }                                                         \
238*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
239*56bb7041Schristos #else
240*56bb7041Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
241*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
242*56bb7041Schristos #endif
243*56bb7041Schristos 
244*56bb7041Schristos /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
245*56bb7041Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
246*56bb7041Schristos    except that the C function func may have a slightly different declaration.
247*56bb7041Schristos    A cast is used to silence the "invalid conversion" error that would
248*56bb7041Schristos    otherwise occur.  */
249*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
250*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
251*56bb7041Schristos     namespace GNULIB_NAMESPACE                          \
252*56bb7041Schristos     {                                                   \
253*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper      \
254*56bb7041Schristos       {                                                 \
255*56bb7041Schristos         typedef rettype (*type) parameters;             \
256*56bb7041Schristos                                                         \
257*56bb7041Schristos         inline operator type () const                   \
258*56bb7041Schristos         {                                               \
259*56bb7041Schristos           return reinterpret_cast<type>(::func);        \
260*56bb7041Schristos         }                                               \
261*56bb7041Schristos       } func = {};                                      \
262*56bb7041Schristos     }                                                   \
263*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
264*56bb7041Schristos #else
265*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
266*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
267*56bb7041Schristos #endif
268*56bb7041Schristos 
269*56bb7041Schristos /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
270*56bb7041Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
271*56bb7041Schristos    except that the C function is picked among a set of overloaded functions,
272*56bb7041Schristos    namely the one with rettype2 and parameters2.  Two consecutive casts
273*56bb7041Schristos    are used to silence the "cannot find a match" and "invalid conversion"
274*56bb7041Schristos    errors that would otherwise occur.  */
275*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
276*56bb7041Schristos   /* The outer cast must be a reinterpret_cast.
277*56bb7041Schristos      The inner cast: When the function is defined as a set of overloaded
278*56bb7041Schristos      functions, it works as a static_cast<>, choosing the designated variant.
279*56bb7041Schristos      When the function is defined as a single variant, it works as a
280*56bb7041Schristos      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
281*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
282*56bb7041Schristos     namespace GNULIB_NAMESPACE                                                \
283*56bb7041Schristos     {                                                                         \
284*56bb7041Schristos       static const struct _gl_ ## func ## _wrapper                            \
285*56bb7041Schristos       {                                                                       \
286*56bb7041Schristos         typedef rettype (*type) parameters;                                   \
287*56bb7041Schristos                                                                               \
288*56bb7041Schristos         inline operator type () const                                         \
289*56bb7041Schristos         {                                                                     \
290*56bb7041Schristos           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
291*56bb7041Schristos         }                                                                     \
292*56bb7041Schristos       } func = {};                                                            \
293*56bb7041Schristos     }                                                                         \
294*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
295*56bb7041Schristos #else
296*56bb7041Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
297*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
298*56bb7041Schristos #endif
299*56bb7041Schristos 
300*56bb7041Schristos /* _GL_CXXALIASWARN (func);
301*56bb7041Schristos    causes a warning to be emitted when ::func is used but not when
302*56bb7041Schristos    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
303*56bb7041Schristos    variants.  */
304*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
305*56bb7041Schristos # define _GL_CXXALIASWARN(func) \
306*56bb7041Schristos    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
307*56bb7041Schristos # define _GL_CXXALIASWARN_1(func,namespace) \
308*56bb7041Schristos    _GL_CXXALIASWARN_2 (func, namespace)
309*56bb7041Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
310*56bb7041Schristos    we enable the warning only when not optimizing.  */
311*56bb7041Schristos # if !__OPTIMIZE__
312*56bb7041Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
313*56bb7041Schristos     _GL_WARN_ON_USE (func, \
314*56bb7041Schristos                      "The symbol ::" #func " refers to the system function. " \
315*56bb7041Schristos                      "Use " #namespace "::" #func " instead.")
316*56bb7041Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
317*56bb7041Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
318*56bb7041Schristos      extern __typeof__ (func) func
319*56bb7041Schristos # else
320*56bb7041Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
321*56bb7041Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
322*56bb7041Schristos # endif
323*56bb7041Schristos #else
324*56bb7041Schristos # define _GL_CXXALIASWARN(func) \
325*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
326*56bb7041Schristos #endif
327*56bb7041Schristos 
328*56bb7041Schristos /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
329*56bb7041Schristos    causes a warning to be emitted when the given overloaded variant of ::func
330*56bb7041Schristos    is used but not when GNULIB_NAMESPACE::func is used.  */
331*56bb7041Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
332*56bb7041Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
333*56bb7041Schristos    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
334*56bb7041Schristos                         GNULIB_NAMESPACE)
335*56bb7041Schristos # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
336*56bb7041Schristos    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
337*56bb7041Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
338*56bb7041Schristos    we enable the warning only when not optimizing.  */
339*56bb7041Schristos # if !__OPTIMIZE__
340*56bb7041Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
341*56bb7041Schristos     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
342*56bb7041Schristos                          "The symbol ::" #func " refers to the system function. " \
343*56bb7041Schristos                          "Use " #namespace "::" #func " instead.")
344*56bb7041Schristos # else
345*56bb7041Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
346*56bb7041Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
347*56bb7041Schristos # endif
348*56bb7041Schristos #else
349*56bb7041Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
350*56bb7041Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
351*56bb7041Schristos #endif
352*56bb7041Schristos 
353*56bb7041Schristos #endif /* _GL_CXXDEFS_H */
354*56bb7041Schristos 
355*56bb7041Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
356*56bb7041Schristos /* A C macro for declaring that specific arguments must not be NULL.
357*56bb7041Schristos    Copyright (C) 2009-2020 Free Software Foundation, Inc.
358*56bb7041Schristos 
359*56bb7041Schristos    This program is free software: you can redistribute it and/or modify it
360*56bb7041Schristos    under the terms of the GNU General Public License as published
361*56bb7041Schristos    by the Free Software Foundation; either version 3 of the License, or
362*56bb7041Schristos    (at your option) any later version.
363*56bb7041Schristos 
364*56bb7041Schristos    This program is distributed in the hope that it will be useful,
365*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
366*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
367*56bb7041Schristos    General Public License for more details.
368*56bb7041Schristos 
369*56bb7041Schristos    You should have received a copy of the GNU General Public License
370*56bb7041Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
371*56bb7041Schristos 
372*56bb7041Schristos /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
373*56bb7041Schristos    that the values passed as arguments n, ..., m must be non-NULL pointers.
374*56bb7041Schristos    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
375*56bb7041Schristos #ifndef _GL_ARG_NONNULL
376*56bb7041Schristos # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
377*56bb7041Schristos #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
378*56bb7041Schristos # else
379*56bb7041Schristos #  define _GL_ARG_NONNULL(params)
380*56bb7041Schristos # endif
381*56bb7041Schristos #endif
382*56bb7041Schristos 
383*56bb7041Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
384*56bb7041Schristos /* A C macro for emitting warnings if a function is used.
385*56bb7041Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
386*56bb7041Schristos 
387*56bb7041Schristos    This program is free software: you can redistribute it and/or modify it
388*56bb7041Schristos    under the terms of the GNU General Public License as published
389*56bb7041Schristos    by the Free Software Foundation; either version 3 of the License, or
390*56bb7041Schristos    (at your option) any later version.
391*56bb7041Schristos 
392*56bb7041Schristos    This program is distributed in the hope that it will be useful,
393*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
394*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
395*56bb7041Schristos    General Public License for more details.
396*56bb7041Schristos 
397*56bb7041Schristos    You should have received a copy of the GNU General Public License
398*56bb7041Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
399*56bb7041Schristos 
400*56bb7041Schristos /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
401*56bb7041Schristos    for FUNCTION which will then trigger a compiler warning containing
402*56bb7041Schristos    the text of "literal string" anywhere that function is called, if
403*56bb7041Schristos    supported by the compiler.  If the compiler does not support this
404*56bb7041Schristos    feature, the macro expands to an unused extern declaration.
405*56bb7041Schristos 
406*56bb7041Schristos    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
407*56bb7041Schristos    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
408*56bb7041Schristos    this feature, it expands to empty.
409*56bb7041Schristos 
410*56bb7041Schristos    These macros are useful for marking a function as a potential
411*56bb7041Schristos    portability trap, with the intent that "literal string" include
412*56bb7041Schristos    instructions on the replacement function that should be used
413*56bb7041Schristos    instead.
414*56bb7041Schristos    _GL_WARN_ON_USE is for functions with 'extern' linkage.
415*56bb7041Schristos    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
416*56bb7041Schristos    linkage.
417*56bb7041Schristos 
418*56bb7041Schristos    However, one of the reasons that a function is a portability trap is
419*56bb7041Schristos    if it has the wrong signature.  Declaring FUNCTION with a different
420*56bb7041Schristos    signature in C is a compilation error, so this macro must use the
421*56bb7041Schristos    same type as any existing declaration so that programs that avoid
422*56bb7041Schristos    the problematic FUNCTION do not fail to compile merely because they
423*56bb7041Schristos    included a header that poisoned the function.  But this implies that
424*56bb7041Schristos    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
425*56bb7041Schristos    have a declaration.  Use of this macro implies that there must not
426*56bb7041Schristos    be any other macro hiding the declaration of FUNCTION; but
427*56bb7041Schristos    undefining FUNCTION first is part of the poisoning process anyway
428*56bb7041Schristos    (although for symbols that are provided only via a macro, the result
429*56bb7041Schristos    is a compilation error rather than a warning containing
430*56bb7041Schristos    "literal string").  Also note that in C++, it is only safe to use if
431*56bb7041Schristos    FUNCTION has no overloads.
432*56bb7041Schristos 
433*56bb7041Schristos    For an example, it is possible to poison 'getline' by:
434*56bb7041Schristos    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
435*56bb7041Schristos      [getline]) in configure.ac, which potentially defines
436*56bb7041Schristos      HAVE_RAW_DECL_GETLINE
437*56bb7041Schristos    - adding this code to a header that wraps the system <stdio.h>:
438*56bb7041Schristos      #undef getline
439*56bb7041Schristos      #if HAVE_RAW_DECL_GETLINE
440*56bb7041Schristos      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
441*56bb7041Schristos        "not universally present; use the gnulib module getline");
442*56bb7041Schristos      #endif
443*56bb7041Schristos 
444*56bb7041Schristos    It is not possible to directly poison global variables.  But it is
445*56bb7041Schristos    possible to write a wrapper accessor function, and poison that
446*56bb7041Schristos    (less common usage, like &environ, will cause a compilation error
447*56bb7041Schristos    rather than issue the nice warning, but the end result of informing
448*56bb7041Schristos    the developer about their portability problem is still achieved):
449*56bb7041Schristos      #if HAVE_RAW_DECL_ENVIRON
450*56bb7041Schristos      static char ***
451*56bb7041Schristos      rpl_environ (void) { return &environ; }
452*56bb7041Schristos      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
453*56bb7041Schristos      # undef environ
454*56bb7041Schristos      # define environ (*rpl_environ ())
455*56bb7041Schristos      #endif
456*56bb7041Schristos    or better (avoiding contradictory use of 'static' and 'extern'):
457*56bb7041Schristos      #if HAVE_RAW_DECL_ENVIRON
458*56bb7041Schristos      static char ***
459*56bb7041Schristos      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
460*56bb7041Schristos      rpl_environ (void) { return &environ; }
461*56bb7041Schristos      # undef environ
462*56bb7041Schristos      # define environ (*rpl_environ ())
463*56bb7041Schristos      #endif
464*56bb7041Schristos    */
465*56bb7041Schristos #ifndef _GL_WARN_ON_USE
466*56bb7041Schristos 
467*56bb7041Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
468*56bb7041Schristos /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
469*56bb7041Schristos #  define _GL_WARN_ON_USE(function, message) \
470*56bb7041Schristos extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
471*56bb7041Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
472*56bb7041Schristos   __attribute__ ((__warning__ (message)))
473*56bb7041Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
474*56bb7041Schristos /* Verify the existence of the function.  */
475*56bb7041Schristos #  define _GL_WARN_ON_USE(function, message) \
476*56bb7041Schristos extern __typeof__ (function) function
477*56bb7041Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
478*56bb7041Schristos # else /* Unsupported.  */
479*56bb7041Schristos #  define _GL_WARN_ON_USE(function, message) \
480*56bb7041Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
481*56bb7041Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
482*56bb7041Schristos # endif
483*56bb7041Schristos #endif
484*56bb7041Schristos 
485*56bb7041Schristos /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
486*56bb7041Schristos    is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
487*56bb7041Schristos    function is declared with the given prototype, consisting of return type,
488*56bb7041Schristos    parameters, and attributes.
489*56bb7041Schristos    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
490*56bb7041Schristos    not work in this case.  */
491*56bb7041Schristos #ifndef _GL_WARN_ON_USE_CXX
492*56bb7041Schristos # if !defined __cplusplus
493*56bb7041Schristos #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
494*56bb7041Schristos      _GL_WARN_ON_USE (function, msg)
495*56bb7041Schristos # else
496*56bb7041Schristos #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
497*56bb7041Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
498*56bb7041Schristos extern rettype function parameters_and_attributes \
499*56bb7041Schristos      __attribute__ ((__warning__ (msg)))
500*56bb7041Schristos #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
501*56bb7041Schristos /* Verify the existence of the function.  */
502*56bb7041Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
503*56bb7041Schristos extern rettype function parameters_and_attributes
504*56bb7041Schristos #  else /* Unsupported.  */
505*56bb7041Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
506*56bb7041Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
507*56bb7041Schristos #  endif
508*56bb7041Schristos # endif
509*56bb7041Schristos #endif
510*56bb7041Schristos 
511*56bb7041Schristos /* _GL_WARN_EXTERN_C declaration;
512*56bb7041Schristos    performs the declaration with C linkage.  */
513*56bb7041Schristos #ifndef _GL_WARN_EXTERN_C
514*56bb7041Schristos # if defined __cplusplus
515*56bb7041Schristos #  define _GL_WARN_EXTERN_C extern "C"
516*56bb7041Schristos # else
517*56bb7041Schristos #  define _GL_WARN_EXTERN_C extern
518*56bb7041Schristos # endif
519*56bb7041Schristos #endif
520*56bb7041Schristos 
521*56bb7041Schristos #if !1 || 1
522*56bb7041Schristos 
523*56bb7041Schristos /* We #undef these before defining them because some losing systems
524*56bb7041Schristos    (HP-UX A.08.07 for example) define these in <unistd.h>.  */
525*56bb7041Schristos #undef  FNM_PATHNAME
526*56bb7041Schristos #undef  FNM_NOESCAPE
527*56bb7041Schristos #undef  FNM_PERIOD
528*56bb7041Schristos 
529*56bb7041Schristos /* Bits set in the FLAGS argument to 'fnmatch'.  */
530*56bb7041Schristos #define FNM_PATHNAME    (1 << 0) /* No wildcard can ever match '/'.  */
531*56bb7041Schristos #define FNM_NOESCAPE    (1 << 1) /* Backslashes don't quote special chars.  */
532*56bb7041Schristos #define FNM_PERIOD      (1 << 2) /* Leading '.' is matched only explicitly.  */
533*56bb7041Schristos 
534*56bb7041Schristos #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
535*56bb7041Schristos # define FNM_FILE_NAME   FNM_PATHNAME   /* Preferred GNU name.  */
536*56bb7041Schristos # define FNM_LEADING_DIR (1 << 3)       /* Ignore '/...' after a match.  */
537*56bb7041Schristos # define FNM_CASEFOLD    (1 << 4)       /* Compare without regard to case.  */
538*56bb7041Schristos # define FNM_EXTMATCH    (1 << 5)       /* Use ksh-like extended matching. */
539*56bb7041Schristos #endif
540*56bb7041Schristos 
541*56bb7041Schristos /* Value returned by 'fnmatch' if STRING does not match PATTERN.  */
542*56bb7041Schristos #define FNM_NOMATCH     1
543*56bb7041Schristos 
544*56bb7041Schristos /* This value is returned if the implementation does not support
545*56bb7041Schristos    'fnmatch'.  Since this is not the case here it will never be
546*56bb7041Schristos    returned but the conformance test suites still require the symbol
547*56bb7041Schristos    to be defined.  */
548*56bb7041Schristos #ifdef _XOPEN_SOURCE
549*56bb7041Schristos # define FNM_NOSYS      (-1)
550*56bb7041Schristos #endif
551*56bb7041Schristos 
552*56bb7041Schristos #endif
553*56bb7041Schristos 
554*56bb7041Schristos 
555*56bb7041Schristos #if 1
556*56bb7041Schristos /* Match NAME against the file name pattern PATTERN,
557*56bb7041Schristos    returning zero if it matches, FNM_NOMATCH if not.  */
558*56bb7041Schristos # if 1
559*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
560*56bb7041Schristos #   define fnmatch rpl_fnmatch
561*56bb7041Schristos #  endif
562*56bb7041Schristos _GL_FUNCDECL_RPL (fnmatch, int,
563*56bb7041Schristos                   (const char *pattern, const char *name, int flags)
564*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 2)));
565*56bb7041Schristos _GL_CXXALIAS_RPL (fnmatch, int,
566*56bb7041Schristos                   (const char *pattern, const char *name, int flags));
567*56bb7041Schristos # else
568*56bb7041Schristos #  if !1
569*56bb7041Schristos _GL_FUNCDECL_SYS (fnmatch, int,
570*56bb7041Schristos                   (const char *pattern, const char *name, int flags)
571*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 2)));
572*56bb7041Schristos #  endif
573*56bb7041Schristos _GL_CXXALIAS_SYS (fnmatch, int,
574*56bb7041Schristos                   (const char *pattern, const char *name, int flags));
575*56bb7041Schristos # endif
576*56bb7041Schristos # if !GNULIB_FNMATCH_GNU && __GLIBC__ >= 2
577*56bb7041Schristos _GL_CXXALIASWARN (fnmatch);
578*56bb7041Schristos # endif
579*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
580*56bb7041Schristos # undef fnmatch
581*56bb7041Schristos # if HAVE_RAW_DECL_FNMATCH
582*56bb7041Schristos _GL_WARN_ON_USE (fnmatch,
583*56bb7041Schristos                  "fnmatch does not portably work - "
584*56bb7041Schristos                  "use gnulib module fnmatch for portability or gnulib module fnmatch-gnu for a glibc compatible implementation");
585*56bb7041Schristos # endif
586*56bb7041Schristos #endif
587*56bb7041Schristos 
588*56bb7041Schristos 
589*56bb7041Schristos #endif /* _GL_FNMATCH_H */
590*56bb7041Schristos #endif /* _GL_FNMATCH_H */
591