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 <signal.h>.
7*fd82c4c4Schristos 
8*fd82c4c4Schristos    Copyright (C) 2006-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 of the License, or
13*fd82c4c4Schristos    (at your option) 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_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
29*fd82c4c4Schristos /* Special invocation convention:
30*fd82c4c4Schristos    - Inside glibc header files.
31*fd82c4c4Schristos    - On glibc systems we have a sequence of nested includes
32*fd82c4c4Schristos      <signal.h> -> <ucontext.h> -> <signal.h>.
33*fd82c4c4Schristos      In this situation, the functions are not yet declared, therefore we cannot
34*fd82c4c4Schristos      provide the C++ aliases.
35*fd82c4c4Schristos    - On glibc systems with GCC 4.3 we have a sequence of nested includes
36*fd82c4c4Schristos      <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>.
37*fd82c4c4Schristos      In this situation, some of the functions are not yet declared, therefore
38*fd82c4c4Schristos      we cannot provide the C++ aliases.  */
39*fd82c4c4Schristos 
40*fd82c4c4Schristos # include_next <signal.h>
41*fd82c4c4Schristos 
42*fd82c4c4Schristos #else
43*fd82c4c4Schristos /* Normal invocation convention.  */
44*fd82c4c4Schristos 
45*fd82c4c4Schristos #ifndef _GL_SIGNAL_H
46*fd82c4c4Schristos 
47*fd82c4c4Schristos #define _GL_ALREADY_INCLUDING_SIGNAL_H
48*fd82c4c4Schristos 
49*fd82c4c4Schristos /* Define pid_t, uid_t.
50*fd82c4c4Schristos    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
51*fd82c4c4Schristos    On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes
52*fd82c4c4Schristos    us; so include <sys/types.h> now, before the second inclusion guard.  */
53*fd82c4c4Schristos #include <sys/types.h>
54*fd82c4c4Schristos 
55*fd82c4c4Schristos /* The include_next requires a split double-inclusion guard.  */
56*fd82c4c4Schristos #include_next <signal.h>
57*fd82c4c4Schristos 
58*fd82c4c4Schristos #undef _GL_ALREADY_INCLUDING_SIGNAL_H
59*fd82c4c4Schristos 
60*fd82c4c4Schristos #ifndef _GL_SIGNAL_H
61*fd82c4c4Schristos #define _GL_SIGNAL_H
62*fd82c4c4Schristos 
63*fd82c4c4Schristos /* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android
64*fd82c4c4Schristos    declare pthread_sigmask in <pthread.h>, not in <signal.h>.
65*fd82c4c4Schristos    But avoid namespace pollution on glibc systems.*/
66*fd82c4c4Schristos #if (0 || defined GNULIB_POSIXCHECK) \
67*fd82c4c4Schristos     && ((defined __APPLE__ && defined __MACH__) \
68*fd82c4c4Schristos         || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \
69*fd82c4c4Schristos         || defined __sun || defined __ANDROID__) \
70*fd82c4c4Schristos     && ! defined __GLIBC__
71*fd82c4c4Schristos # include <pthread.h>
72*fd82c4c4Schristos #endif
73*fd82c4c4Schristos 
74*fd82c4c4Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
75*fd82c4c4Schristos /* C++ compatible function declaration macros.
76*fd82c4c4Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
77*fd82c4c4Schristos 
78*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
79*fd82c4c4Schristos    under the terms of the GNU General Public License as published
80*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
81*fd82c4c4Schristos    (at your option) any later version.
82*fd82c4c4Schristos 
83*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
84*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
85*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
86*fd82c4c4Schristos    General Public License for more details.
87*fd82c4c4Schristos 
88*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
89*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
90*fd82c4c4Schristos 
91*fd82c4c4Schristos #ifndef _GL_CXXDEFS_H
92*fd82c4c4Schristos #define _GL_CXXDEFS_H
93*fd82c4c4Schristos 
94*fd82c4c4Schristos /* Begin/end the GNULIB_NAMESPACE namespace.  */
95*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
96*fd82c4c4Schristos # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
97*fd82c4c4Schristos # define _GL_END_NAMESPACE }
98*fd82c4c4Schristos #else
99*fd82c4c4Schristos # define _GL_BEGIN_NAMESPACE
100*fd82c4c4Schristos # define _GL_END_NAMESPACE
101*fd82c4c4Schristos #endif
102*fd82c4c4Schristos 
103*fd82c4c4Schristos /* The three most frequent use cases of these macros are:
104*fd82c4c4Schristos 
105*fd82c4c4Schristos    * For providing a substitute for a function that is missing on some
106*fd82c4c4Schristos      platforms, but is declared and works fine on the platforms on which
107*fd82c4c4Schristos      it exists:
108*fd82c4c4Schristos 
109*fd82c4c4Schristos        #if @GNULIB_FOO@
110*fd82c4c4Schristos        # if !@HAVE_FOO@
111*fd82c4c4Schristos        _GL_FUNCDECL_SYS (foo, ...);
112*fd82c4c4Schristos        # endif
113*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
114*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
115*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
116*fd82c4c4Schristos        ...
117*fd82c4c4Schristos        #endif
118*fd82c4c4Schristos 
119*fd82c4c4Schristos    * For providing a replacement for a function that exists on all platforms,
120*fd82c4c4Schristos      but is broken/insufficient and needs to be replaced on some platforms:
121*fd82c4c4Schristos 
122*fd82c4c4Schristos        #if @GNULIB_FOO@
123*fd82c4c4Schristos        # if @REPLACE_FOO@
124*fd82c4c4Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
125*fd82c4c4Schristos        #   undef foo
126*fd82c4c4Schristos        #   define foo rpl_foo
127*fd82c4c4Schristos        #  endif
128*fd82c4c4Schristos        _GL_FUNCDECL_RPL (foo, ...);
129*fd82c4c4Schristos        _GL_CXXALIAS_RPL (foo, ...);
130*fd82c4c4Schristos        # else
131*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
132*fd82c4c4Schristos        # endif
133*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
134*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
135*fd82c4c4Schristos        ...
136*fd82c4c4Schristos        #endif
137*fd82c4c4Schristos 
138*fd82c4c4Schristos    * For providing a replacement for a function that exists on some platforms
139*fd82c4c4Schristos      but is broken/insufficient and needs to be replaced on some of them and
140*fd82c4c4Schristos      is additionally either missing or undeclared on some other platforms:
141*fd82c4c4Schristos 
142*fd82c4c4Schristos        #if @GNULIB_FOO@
143*fd82c4c4Schristos        # if @REPLACE_FOO@
144*fd82c4c4Schristos        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
145*fd82c4c4Schristos        #   undef foo
146*fd82c4c4Schristos        #   define foo rpl_foo
147*fd82c4c4Schristos        #  endif
148*fd82c4c4Schristos        _GL_FUNCDECL_RPL (foo, ...);
149*fd82c4c4Schristos        _GL_CXXALIAS_RPL (foo, ...);
150*fd82c4c4Schristos        # else
151*fd82c4c4Schristos        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
152*fd82c4c4Schristos        _GL_FUNCDECL_SYS (foo, ...);
153*fd82c4c4Schristos        #  endif
154*fd82c4c4Schristos        _GL_CXXALIAS_SYS (foo, ...);
155*fd82c4c4Schristos        # endif
156*fd82c4c4Schristos        _GL_CXXALIASWARN (foo);
157*fd82c4c4Schristos        #elif defined GNULIB_POSIXCHECK
158*fd82c4c4Schristos        ...
159*fd82c4c4Schristos        #endif
160*fd82c4c4Schristos */
161*fd82c4c4Schristos 
162*fd82c4c4Schristos /* _GL_EXTERN_C declaration;
163*fd82c4c4Schristos    performs the declaration with C linkage.  */
164*fd82c4c4Schristos #if defined __cplusplus
165*fd82c4c4Schristos # define _GL_EXTERN_C extern "C"
166*fd82c4c4Schristos #else
167*fd82c4c4Schristos # define _GL_EXTERN_C extern
168*fd82c4c4Schristos #endif
169*fd82c4c4Schristos 
170*fd82c4c4Schristos /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
171*fd82c4c4Schristos    declares a replacement function, named rpl_func, with the given prototype,
172*fd82c4c4Schristos    consisting of return type, parameters, and attributes.
173*fd82c4c4Schristos    Example:
174*fd82c4c4Schristos      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
175*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
176*fd82c4c4Schristos  */
177*fd82c4c4Schristos #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
178*fd82c4c4Schristos   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
179*fd82c4c4Schristos #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
180*fd82c4c4Schristos   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
181*fd82c4c4Schristos 
182*fd82c4c4Schristos /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
183*fd82c4c4Schristos    declares the system function, named func, with the given prototype,
184*fd82c4c4Schristos    consisting of return type, parameters, and attributes.
185*fd82c4c4Schristos    Example:
186*fd82c4c4Schristos      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
187*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
188*fd82c4c4Schristos  */
189*fd82c4c4Schristos #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
190*fd82c4c4Schristos   _GL_EXTERN_C rettype func parameters_and_attributes
191*fd82c4c4Schristos 
192*fd82c4c4Schristos /* _GL_CXXALIAS_RPL (func, rettype, parameters);
193*fd82c4c4Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
194*fd82c4c4Schristos    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
195*fd82c4c4Schristos    Example:
196*fd82c4c4Schristos      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
197*fd82c4c4Schristos 
198*fd82c4c4Schristos    Wrapping rpl_func in an object with an inline conversion operator
199*fd82c4c4Schristos    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
200*fd82c4c4Schristos    actually used in the program.  */
201*fd82c4c4Schristos #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
202*fd82c4c4Schristos   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
203*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
204*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
205*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                \
206*fd82c4c4Schristos     {                                                         \
207*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper            \
208*fd82c4c4Schristos       {                                                       \
209*fd82c4c4Schristos         typedef rettype (*type) parameters;                   \
210*fd82c4c4Schristos                                                               \
211*fd82c4c4Schristos         inline operator type () const                         \
212*fd82c4c4Schristos         {                                                     \
213*fd82c4c4Schristos           return ::rpl_func;                                  \
214*fd82c4c4Schristos         }                                                     \
215*fd82c4c4Schristos       } func = {};                                            \
216*fd82c4c4Schristos     }                                                         \
217*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
218*fd82c4c4Schristos #else
219*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
220*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
221*fd82c4c4Schristos #endif
222*fd82c4c4Schristos 
223*fd82c4c4Schristos /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
224*fd82c4c4Schristos    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
225*fd82c4c4Schristos    except that the C function rpl_func may have a slightly different
226*fd82c4c4Schristos    declaration.  A cast is used to silence the "invalid conversion" error
227*fd82c4c4Schristos    that would otherwise occur.  */
228*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
229*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
230*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                     \
231*fd82c4c4Schristos     {                                                              \
232*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper                 \
233*fd82c4c4Schristos       {                                                            \
234*fd82c4c4Schristos         typedef rettype (*type) parameters;                        \
235*fd82c4c4Schristos                                                                    \
236*fd82c4c4Schristos         inline operator type () const                              \
237*fd82c4c4Schristos         {                                                          \
238*fd82c4c4Schristos           return reinterpret_cast<type>(::rpl_func);               \
239*fd82c4c4Schristos         }                                                          \
240*fd82c4c4Schristos       } func = {};                                                 \
241*fd82c4c4Schristos     }                                                              \
242*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
243*fd82c4c4Schristos #else
244*fd82c4c4Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
245*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
246*fd82c4c4Schristos #endif
247*fd82c4c4Schristos 
248*fd82c4c4Schristos /* _GL_CXXALIAS_SYS (func, rettype, parameters);
249*fd82c4c4Schristos    declares a C++ alias called GNULIB_NAMESPACE::func
250*fd82c4c4Schristos    that redirects to the system provided function func, if GNULIB_NAMESPACE
251*fd82c4c4Schristos    is defined.
252*fd82c4c4Schristos    Example:
253*fd82c4c4Schristos      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
254*fd82c4c4Schristos 
255*fd82c4c4Schristos    Wrapping func in an object with an inline conversion operator
256*fd82c4c4Schristos    avoids a reference to func unless GNULIB_NAMESPACE::func is
257*fd82c4c4Schristos    actually used in the program.  */
258*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
259*fd82c4c4Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
260*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                \
261*fd82c4c4Schristos     {                                                         \
262*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper            \
263*fd82c4c4Schristos       {                                                       \
264*fd82c4c4Schristos         typedef rettype (*type) parameters;                   \
265*fd82c4c4Schristos                                                               \
266*fd82c4c4Schristos         inline operator type () const                         \
267*fd82c4c4Schristos         {                                                     \
268*fd82c4c4Schristos           return ::func;                                      \
269*fd82c4c4Schristos         }                                                     \
270*fd82c4c4Schristos       } func = {};                                            \
271*fd82c4c4Schristos     }                                                         \
272*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
273*fd82c4c4Schristos #else
274*fd82c4c4Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
275*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
276*fd82c4c4Schristos #endif
277*fd82c4c4Schristos 
278*fd82c4c4Schristos /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
279*fd82c4c4Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
280*fd82c4c4Schristos    except that the C function func may have a slightly different declaration.
281*fd82c4c4Schristos    A cast is used to silence the "invalid conversion" error that would
282*fd82c4c4Schristos    otherwise occur.  */
283*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
284*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
285*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                          \
286*fd82c4c4Schristos     {                                                   \
287*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper      \
288*fd82c4c4Schristos       {                                                 \
289*fd82c4c4Schristos         typedef rettype (*type) parameters;             \
290*fd82c4c4Schristos                                                         \
291*fd82c4c4Schristos         inline operator type () const                   \
292*fd82c4c4Schristos         {                                               \
293*fd82c4c4Schristos           return reinterpret_cast<type>(::func);        \
294*fd82c4c4Schristos         }                                               \
295*fd82c4c4Schristos       } func = {};                                      \
296*fd82c4c4Schristos     }                                                   \
297*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
298*fd82c4c4Schristos #else
299*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
300*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
301*fd82c4c4Schristos #endif
302*fd82c4c4Schristos 
303*fd82c4c4Schristos /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
304*fd82c4c4Schristos    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
305*fd82c4c4Schristos    except that the C function is picked among a set of overloaded functions,
306*fd82c4c4Schristos    namely the one with rettype2 and parameters2.  Two consecutive casts
307*fd82c4c4Schristos    are used to silence the "cannot find a match" and "invalid conversion"
308*fd82c4c4Schristos    errors that would otherwise occur.  */
309*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
310*fd82c4c4Schristos   /* The outer cast must be a reinterpret_cast.
311*fd82c4c4Schristos      The inner cast: When the function is defined as a set of overloaded
312*fd82c4c4Schristos      functions, it works as a static_cast<>, choosing the designated variant.
313*fd82c4c4Schristos      When the function is defined as a single variant, it works as a
314*fd82c4c4Schristos      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
315*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
316*fd82c4c4Schristos     namespace GNULIB_NAMESPACE                                                \
317*fd82c4c4Schristos     {                                                                         \
318*fd82c4c4Schristos       static const struct _gl_ ## func ## _wrapper                            \
319*fd82c4c4Schristos       {                                                                       \
320*fd82c4c4Schristos         typedef rettype (*type) parameters;                                   \
321*fd82c4c4Schristos                                                                               \
322*fd82c4c4Schristos         inline operator type () const                                         \
323*fd82c4c4Schristos         {                                                                     \
324*fd82c4c4Schristos           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
325*fd82c4c4Schristos         }                                                                     \
326*fd82c4c4Schristos       } func = {};                                                            \
327*fd82c4c4Schristos     }                                                                         \
328*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
329*fd82c4c4Schristos #else
330*fd82c4c4Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
331*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
332*fd82c4c4Schristos #endif
333*fd82c4c4Schristos 
334*fd82c4c4Schristos /* _GL_CXXALIASWARN (func);
335*fd82c4c4Schristos    causes a warning to be emitted when ::func is used but not when
336*fd82c4c4Schristos    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
337*fd82c4c4Schristos    variants.  */
338*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
339*fd82c4c4Schristos # define _GL_CXXALIASWARN(func) \
340*fd82c4c4Schristos    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
341*fd82c4c4Schristos # define _GL_CXXALIASWARN_1(func,namespace) \
342*fd82c4c4Schristos    _GL_CXXALIASWARN_2 (func, namespace)
343*fd82c4c4Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
344*fd82c4c4Schristos    we enable the warning only when not optimizing.  */
345*fd82c4c4Schristos # if !__OPTIMIZE__
346*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
347*fd82c4c4Schristos     _GL_WARN_ON_USE (func, \
348*fd82c4c4Schristos                      "The symbol ::" #func " refers to the system function. " \
349*fd82c4c4Schristos                      "Use " #namespace "::" #func " instead.")
350*fd82c4c4Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
351*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
352*fd82c4c4Schristos      extern __typeof__ (func) func
353*fd82c4c4Schristos # else
354*fd82c4c4Schristos #  define _GL_CXXALIASWARN_2(func,namespace) \
355*fd82c4c4Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
356*fd82c4c4Schristos # endif
357*fd82c4c4Schristos #else
358*fd82c4c4Schristos # define _GL_CXXALIASWARN(func) \
359*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
360*fd82c4c4Schristos #endif
361*fd82c4c4Schristos 
362*fd82c4c4Schristos /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
363*fd82c4c4Schristos    causes a warning to be emitted when the given overloaded variant of ::func
364*fd82c4c4Schristos    is used but not when GNULIB_NAMESPACE::func is used.  */
365*fd82c4c4Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE
366*fd82c4c4Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
367*fd82c4c4Schristos    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
368*fd82c4c4Schristos                         GNULIB_NAMESPACE)
369*fd82c4c4Schristos # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
370*fd82c4c4Schristos    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
371*fd82c4c4Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
372*fd82c4c4Schristos    we enable the warning only when not optimizing.  */
373*fd82c4c4Schristos # if !__OPTIMIZE__
374*fd82c4c4Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
375*fd82c4c4Schristos     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
376*fd82c4c4Schristos                          "The symbol ::" #func " refers to the system function. " \
377*fd82c4c4Schristos                          "Use " #namespace "::" #func " instead.")
378*fd82c4c4Schristos # else
379*fd82c4c4Schristos #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
380*fd82c4c4Schristos      _GL_EXTERN_C int _gl_cxxalias_dummy
381*fd82c4c4Schristos # endif
382*fd82c4c4Schristos #else
383*fd82c4c4Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
384*fd82c4c4Schristos     _GL_EXTERN_C int _gl_cxxalias_dummy
385*fd82c4c4Schristos #endif
386*fd82c4c4Schristos 
387*fd82c4c4Schristos #endif /* _GL_CXXDEFS_H */
388*fd82c4c4Schristos 
389*fd82c4c4Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
390*fd82c4c4Schristos /* A C macro for declaring that specific arguments must not be NULL.
391*fd82c4c4Schristos    Copyright (C) 2009-2020 Free Software Foundation, Inc.
392*fd82c4c4Schristos 
393*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
394*fd82c4c4Schristos    under the terms of the GNU General Public License as published
395*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
396*fd82c4c4Schristos    (at your option) any later version.
397*fd82c4c4Schristos 
398*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
399*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
400*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
401*fd82c4c4Schristos    General Public License for more details.
402*fd82c4c4Schristos 
403*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
404*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
405*fd82c4c4Schristos 
406*fd82c4c4Schristos /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
407*fd82c4c4Schristos    that the values passed as arguments n, ..., m must be non-NULL pointers.
408*fd82c4c4Schristos    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
409*fd82c4c4Schristos #ifndef _GL_ARG_NONNULL
410*fd82c4c4Schristos # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
411*fd82c4c4Schristos #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
412*fd82c4c4Schristos # else
413*fd82c4c4Schristos #  define _GL_ARG_NONNULL(params)
414*fd82c4c4Schristos # endif
415*fd82c4c4Schristos #endif
416*fd82c4c4Schristos 
417*fd82c4c4Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
418*fd82c4c4Schristos /* A C macro for emitting warnings if a function is used.
419*fd82c4c4Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
420*fd82c4c4Schristos 
421*fd82c4c4Schristos    This program is free software: you can redistribute it and/or modify it
422*fd82c4c4Schristos    under the terms of the GNU General Public License as published
423*fd82c4c4Schristos    by the Free Software Foundation; either version 3 of the License, or
424*fd82c4c4Schristos    (at your option) any later version.
425*fd82c4c4Schristos 
426*fd82c4c4Schristos    This program is distributed in the hope that it will be useful,
427*fd82c4c4Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
428*fd82c4c4Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
429*fd82c4c4Schristos    General Public License for more details.
430*fd82c4c4Schristos 
431*fd82c4c4Schristos    You should have received a copy of the GNU General Public License
432*fd82c4c4Schristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
433*fd82c4c4Schristos 
434*fd82c4c4Schristos /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
435*fd82c4c4Schristos    for FUNCTION which will then trigger a compiler warning containing
436*fd82c4c4Schristos    the text of "literal string" anywhere that function is called, if
437*fd82c4c4Schristos    supported by the compiler.  If the compiler does not support this
438*fd82c4c4Schristos    feature, the macro expands to an unused extern declaration.
439*fd82c4c4Schristos 
440*fd82c4c4Schristos    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
441*fd82c4c4Schristos    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
442*fd82c4c4Schristos    this feature, it expands to empty.
443*fd82c4c4Schristos 
444*fd82c4c4Schristos    These macros are useful for marking a function as a potential
445*fd82c4c4Schristos    portability trap, with the intent that "literal string" include
446*fd82c4c4Schristos    instructions on the replacement function that should be used
447*fd82c4c4Schristos    instead.
448*fd82c4c4Schristos    _GL_WARN_ON_USE is for functions with 'extern' linkage.
449*fd82c4c4Schristos    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
450*fd82c4c4Schristos    linkage.
451*fd82c4c4Schristos 
452*fd82c4c4Schristos    However, one of the reasons that a function is a portability trap is
453*fd82c4c4Schristos    if it has the wrong signature.  Declaring FUNCTION with a different
454*fd82c4c4Schristos    signature in C is a compilation error, so this macro must use the
455*fd82c4c4Schristos    same type as any existing declaration so that programs that avoid
456*fd82c4c4Schristos    the problematic FUNCTION do not fail to compile merely because they
457*fd82c4c4Schristos    included a header that poisoned the function.  But this implies that
458*fd82c4c4Schristos    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
459*fd82c4c4Schristos    have a declaration.  Use of this macro implies that there must not
460*fd82c4c4Schristos    be any other macro hiding the declaration of FUNCTION; but
461*fd82c4c4Schristos    undefining FUNCTION first is part of the poisoning process anyway
462*fd82c4c4Schristos    (although for symbols that are provided only via a macro, the result
463*fd82c4c4Schristos    is a compilation error rather than a warning containing
464*fd82c4c4Schristos    "literal string").  Also note that in C++, it is only safe to use if
465*fd82c4c4Schristos    FUNCTION has no overloads.
466*fd82c4c4Schristos 
467*fd82c4c4Schristos    For an example, it is possible to poison 'getline' by:
468*fd82c4c4Schristos    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
469*fd82c4c4Schristos      [getline]) in configure.ac, which potentially defines
470*fd82c4c4Schristos      HAVE_RAW_DECL_GETLINE
471*fd82c4c4Schristos    - adding this code to a header that wraps the system <stdio.h>:
472*fd82c4c4Schristos      #undef getline
473*fd82c4c4Schristos      #if HAVE_RAW_DECL_GETLINE
474*fd82c4c4Schristos      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
475*fd82c4c4Schristos        "not universally present; use the gnulib module getline");
476*fd82c4c4Schristos      #endif
477*fd82c4c4Schristos 
478*fd82c4c4Schristos    It is not possible to directly poison global variables.  But it is
479*fd82c4c4Schristos    possible to write a wrapper accessor function, and poison that
480*fd82c4c4Schristos    (less common usage, like &environ, will cause a compilation error
481*fd82c4c4Schristos    rather than issue the nice warning, but the end result of informing
482*fd82c4c4Schristos    the developer about their portability problem is still achieved):
483*fd82c4c4Schristos      #if HAVE_RAW_DECL_ENVIRON
484*fd82c4c4Schristos      static char ***
485*fd82c4c4Schristos      rpl_environ (void) { return &environ; }
486*fd82c4c4Schristos      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
487*fd82c4c4Schristos      # undef environ
488*fd82c4c4Schristos      # define environ (*rpl_environ ())
489*fd82c4c4Schristos      #endif
490*fd82c4c4Schristos    or better (avoiding contradictory use of 'static' and 'extern'):
491*fd82c4c4Schristos      #if HAVE_RAW_DECL_ENVIRON
492*fd82c4c4Schristos      static char ***
493*fd82c4c4Schristos      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
494*fd82c4c4Schristos      rpl_environ (void) { return &environ; }
495*fd82c4c4Schristos      # undef environ
496*fd82c4c4Schristos      # define environ (*rpl_environ ())
497*fd82c4c4Schristos      #endif
498*fd82c4c4Schristos    */
499*fd82c4c4Schristos #ifndef _GL_WARN_ON_USE
500*fd82c4c4Schristos 
501*fd82c4c4Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
502*fd82c4c4Schristos /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
503*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
504*fd82c4c4Schristos extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
505*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
506*fd82c4c4Schristos   __attribute__ ((__warning__ (message)))
507*fd82c4c4Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
508*fd82c4c4Schristos /* Verify the existence of the function.  */
509*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
510*fd82c4c4Schristos extern __typeof__ (function) function
511*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
512*fd82c4c4Schristos # else /* Unsupported.  */
513*fd82c4c4Schristos #  define _GL_WARN_ON_USE(function, message) \
514*fd82c4c4Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
515*fd82c4c4Schristos #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
516*fd82c4c4Schristos # endif
517*fd82c4c4Schristos #endif
518*fd82c4c4Schristos 
519*fd82c4c4Schristos /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
520*fd82c4c4Schristos    is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
521*fd82c4c4Schristos    function is declared with the given prototype, consisting of return type,
522*fd82c4c4Schristos    parameters, and attributes.
523*fd82c4c4Schristos    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
524*fd82c4c4Schristos    not work in this case.  */
525*fd82c4c4Schristos #ifndef _GL_WARN_ON_USE_CXX
526*fd82c4c4Schristos # if !defined __cplusplus
527*fd82c4c4Schristos #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
528*fd82c4c4Schristos      _GL_WARN_ON_USE (function, msg)
529*fd82c4c4Schristos # else
530*fd82c4c4Schristos #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
531*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
532*fd82c4c4Schristos extern rettype function parameters_and_attributes \
533*fd82c4c4Schristos      __attribute__ ((__warning__ (msg)))
534*fd82c4c4Schristos #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
535*fd82c4c4Schristos /* Verify the existence of the function.  */
536*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
537*fd82c4c4Schristos extern rettype function parameters_and_attributes
538*fd82c4c4Schristos #  else /* Unsupported.  */
539*fd82c4c4Schristos #   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
540*fd82c4c4Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use
541*fd82c4c4Schristos #  endif
542*fd82c4c4Schristos # endif
543*fd82c4c4Schristos #endif
544*fd82c4c4Schristos 
545*fd82c4c4Schristos /* _GL_WARN_EXTERN_C declaration;
546*fd82c4c4Schristos    performs the declaration with C linkage.  */
547*fd82c4c4Schristos #ifndef _GL_WARN_EXTERN_C
548*fd82c4c4Schristos # if defined __cplusplus
549*fd82c4c4Schristos #  define _GL_WARN_EXTERN_C extern "C"
550*fd82c4c4Schristos # else
551*fd82c4c4Schristos #  define _GL_WARN_EXTERN_C extern
552*fd82c4c4Schristos # endif
553*fd82c4c4Schristos #endif
554*fd82c4c4Schristos 
555*fd82c4c4Schristos /* On AIX, sig_atomic_t already includes volatile.  C99 requires that
556*fd82c4c4Schristos    'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
557*fd82c4c4Schristos    Hence, redefine this to a non-volatile type as needed.  */
558*fd82c4c4Schristos #if ! 1
559*fd82c4c4Schristos # if !GNULIB_defined_sig_atomic_t
560*fd82c4c4Schristos typedef int rpl_sig_atomic_t;
561*fd82c4c4Schristos #  undef sig_atomic_t
562*fd82c4c4Schristos #  define sig_atomic_t rpl_sig_atomic_t
563*fd82c4c4Schristos #  define GNULIB_defined_sig_atomic_t 1
564*fd82c4c4Schristos # endif
565*fd82c4c4Schristos #endif
566*fd82c4c4Schristos 
567*fd82c4c4Schristos /* A set or mask of signals.  */
568*fd82c4c4Schristos #if !1
569*fd82c4c4Schristos # if !GNULIB_defined_sigset_t
570*fd82c4c4Schristos typedef unsigned int sigset_t;
571*fd82c4c4Schristos #  define GNULIB_defined_sigset_t 1
572*fd82c4c4Schristos # endif
573*fd82c4c4Schristos #endif
574*fd82c4c4Schristos 
575*fd82c4c4Schristos /* Define sighandler_t, the type of signal handlers.  A GNU extension.  */
576*fd82c4c4Schristos #if !0
577*fd82c4c4Schristos # ifdef __cplusplus
578*fd82c4c4Schristos extern "C" {
579*fd82c4c4Schristos # endif
580*fd82c4c4Schristos # if !GNULIB_defined_sighandler_t
581*fd82c4c4Schristos typedef void (*sighandler_t) (int);
582*fd82c4c4Schristos #  define GNULIB_defined_sighandler_t 1
583*fd82c4c4Schristos # endif
584*fd82c4c4Schristos # ifdef __cplusplus
585*fd82c4c4Schristos }
586*fd82c4c4Schristos # endif
587*fd82c4c4Schristos #endif
588*fd82c4c4Schristos 
589*fd82c4c4Schristos 
590*fd82c4c4Schristos #if 0
591*fd82c4c4Schristos # ifndef SIGPIPE
592*fd82c4c4Schristos /* Define SIGPIPE to a value that does not overlap with other signals.  */
593*fd82c4c4Schristos #  define SIGPIPE 13
594*fd82c4c4Schristos #  define GNULIB_defined_SIGPIPE 1
595*fd82c4c4Schristos /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
596*fd82c4c4Schristos    'write', 'stdio'.  */
597*fd82c4c4Schristos # endif
598*fd82c4c4Schristos #endif
599*fd82c4c4Schristos 
600*fd82c4c4Schristos 
601*fd82c4c4Schristos /* Maximum signal number + 1.  */
602*fd82c4c4Schristos #ifndef NSIG
603*fd82c4c4Schristos # if defined __TANDEM
604*fd82c4c4Schristos #  define NSIG 32
605*fd82c4c4Schristos # endif
606*fd82c4c4Schristos #endif
607*fd82c4c4Schristos 
608*fd82c4c4Schristos 
609*fd82c4c4Schristos #if 0
610*fd82c4c4Schristos # if 0
611*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
612*fd82c4c4Schristos #   undef pthread_sigmask
613*fd82c4c4Schristos #   define pthread_sigmask rpl_pthread_sigmask
614*fd82c4c4Schristos #  endif
615*fd82c4c4Schristos _GL_FUNCDECL_RPL (pthread_sigmask, int,
616*fd82c4c4Schristos                   (int how,
617*fd82c4c4Schristos                    const sigset_t *restrict new_mask,
618*fd82c4c4Schristos                    sigset_t *restrict old_mask));
619*fd82c4c4Schristos _GL_CXXALIAS_RPL (pthread_sigmask, int,
620*fd82c4c4Schristos                   (int how,
621*fd82c4c4Schristos                    const sigset_t *restrict new_mask,
622*fd82c4c4Schristos                    sigset_t *restrict old_mask));
623*fd82c4c4Schristos # else
624*fd82c4c4Schristos #  if !(1 || defined pthread_sigmask)
625*fd82c4c4Schristos _GL_FUNCDECL_SYS (pthread_sigmask, int,
626*fd82c4c4Schristos                   (int how,
627*fd82c4c4Schristos                    const sigset_t *restrict new_mask,
628*fd82c4c4Schristos                    sigset_t *restrict old_mask));
629*fd82c4c4Schristos #  endif
630*fd82c4c4Schristos _GL_CXXALIAS_SYS (pthread_sigmask, int,
631*fd82c4c4Schristos                   (int how,
632*fd82c4c4Schristos                    const sigset_t *restrict new_mask,
633*fd82c4c4Schristos                    sigset_t *restrict old_mask));
634*fd82c4c4Schristos # endif
635*fd82c4c4Schristos # if __GLIBC__ >= 2
636*fd82c4c4Schristos _GL_CXXALIASWARN (pthread_sigmask);
637*fd82c4c4Schristos # endif
638*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
639*fd82c4c4Schristos # undef pthread_sigmask
640*fd82c4c4Schristos # if HAVE_RAW_DECL_PTHREAD_SIGMASK
641*fd82c4c4Schristos _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
642*fd82c4c4Schristos                  "use gnulib module pthread_sigmask for portability");
643*fd82c4c4Schristos # endif
644*fd82c4c4Schristos #endif
645*fd82c4c4Schristos 
646*fd82c4c4Schristos 
647*fd82c4c4Schristos #if 0
648*fd82c4c4Schristos # if 0
649*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650*fd82c4c4Schristos #   undef raise
651*fd82c4c4Schristos #   define raise rpl_raise
652*fd82c4c4Schristos #  endif
653*fd82c4c4Schristos _GL_FUNCDECL_RPL (raise, int, (int sig));
654*fd82c4c4Schristos _GL_CXXALIAS_RPL (raise, int, (int sig));
655*fd82c4c4Schristos # else
656*fd82c4c4Schristos #  if !1
657*fd82c4c4Schristos _GL_FUNCDECL_SYS (raise, int, (int sig));
658*fd82c4c4Schristos #  endif
659*fd82c4c4Schristos _GL_CXXALIAS_SYS (raise, int, (int sig));
660*fd82c4c4Schristos # endif
661*fd82c4c4Schristos # if __GLIBC__ >= 2
662*fd82c4c4Schristos _GL_CXXALIASWARN (raise);
663*fd82c4c4Schristos # endif
664*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
665*fd82c4c4Schristos # undef raise
666*fd82c4c4Schristos /* Assume raise is always declared.  */
667*fd82c4c4Schristos _GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
668*fd82c4c4Schristos                  "use gnulib module raise for portability");
669*fd82c4c4Schristos #endif
670*fd82c4c4Schristos 
671*fd82c4c4Schristos 
672*fd82c4c4Schristos #if 0
673*fd82c4c4Schristos # if !1
674*fd82c4c4Schristos 
675*fd82c4c4Schristos #  ifndef GNULIB_defined_signal_blocking
676*fd82c4c4Schristos #   define GNULIB_defined_signal_blocking 1
677*fd82c4c4Schristos #  endif
678*fd82c4c4Schristos 
679*fd82c4c4Schristos /* Maximum signal number + 1.  */
680*fd82c4c4Schristos #  ifndef NSIG
681*fd82c4c4Schristos #   define NSIG 32
682*fd82c4c4Schristos #  endif
683*fd82c4c4Schristos 
684*fd82c4c4Schristos /* This code supports only 32 signals.  */
685*fd82c4c4Schristos #  if !GNULIB_defined_verify_NSIG_constraint
686*fd82c4c4Schristos typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
687*fd82c4c4Schristos #   define GNULIB_defined_verify_NSIG_constraint 1
688*fd82c4c4Schristos #  endif
689*fd82c4c4Schristos 
690*fd82c4c4Schristos # endif
691*fd82c4c4Schristos 
692*fd82c4c4Schristos /* When also using extern inline, suppress the use of static inline in
693*fd82c4c4Schristos    standard headers of problematic Apple configurations, as Libc at
694*fd82c4c4Schristos    least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
695*fd82c4c4Schristos    <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
696*fd82c4c4Schristos    Perhaps Apple will fix this some day.  */
697*fd82c4c4Schristos #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
698*fd82c4c4Schristos      && (defined __i386__ || defined __x86_64__))
699*fd82c4c4Schristos # undef sigaddset
700*fd82c4c4Schristos # undef sigdelset
701*fd82c4c4Schristos # undef sigemptyset
702*fd82c4c4Schristos # undef sigfillset
703*fd82c4c4Schristos # undef sigismember
704*fd82c4c4Schristos #endif
705*fd82c4c4Schristos 
706*fd82c4c4Schristos /* Test whether a given signal is contained in a signal set.  */
707*fd82c4c4Schristos # if 1
708*fd82c4c4Schristos /* This function is defined as a macro on Mac OS X.  */
709*fd82c4c4Schristos #  if defined __cplusplus && defined GNULIB_NAMESPACE
710*fd82c4c4Schristos #   undef sigismember
711*fd82c4c4Schristos #  endif
712*fd82c4c4Schristos # else
713*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
714*fd82c4c4Schristos                                     _GL_ARG_NONNULL ((1)));
715*fd82c4c4Schristos # endif
716*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig));
717*fd82c4c4Schristos _GL_CXXALIASWARN (sigismember);
718*fd82c4c4Schristos 
719*fd82c4c4Schristos /* Initialize a signal set to the empty set.  */
720*fd82c4c4Schristos # if 1
721*fd82c4c4Schristos /* This function is defined as a macro on Mac OS X.  */
722*fd82c4c4Schristos #  if defined __cplusplus && defined GNULIB_NAMESPACE
723*fd82c4c4Schristos #   undef sigemptyset
724*fd82c4c4Schristos #  endif
725*fd82c4c4Schristos # else
726*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
727*fd82c4c4Schristos # endif
728*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set));
729*fd82c4c4Schristos _GL_CXXALIASWARN (sigemptyset);
730*fd82c4c4Schristos 
731*fd82c4c4Schristos /* Add a signal to a signal set.  */
732*fd82c4c4Schristos # if 1
733*fd82c4c4Schristos /* This function is defined as a macro on Mac OS X.  */
734*fd82c4c4Schristos #  if defined __cplusplus && defined GNULIB_NAMESPACE
735*fd82c4c4Schristos #   undef sigaddset
736*fd82c4c4Schristos #  endif
737*fd82c4c4Schristos # else
738*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
739*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
740*fd82c4c4Schristos # endif
741*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig));
742*fd82c4c4Schristos _GL_CXXALIASWARN (sigaddset);
743*fd82c4c4Schristos 
744*fd82c4c4Schristos /* Remove a signal from a signal set.  */
745*fd82c4c4Schristos # if 1
746*fd82c4c4Schristos /* This function is defined as a macro on Mac OS X.  */
747*fd82c4c4Schristos #  if defined __cplusplus && defined GNULIB_NAMESPACE
748*fd82c4c4Schristos #   undef sigdelset
749*fd82c4c4Schristos #  endif
750*fd82c4c4Schristos # else
751*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
752*fd82c4c4Schristos                                   _GL_ARG_NONNULL ((1)));
753*fd82c4c4Schristos # endif
754*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig));
755*fd82c4c4Schristos _GL_CXXALIASWARN (sigdelset);
756*fd82c4c4Schristos 
757*fd82c4c4Schristos /* Fill a signal set with all possible signals.  */
758*fd82c4c4Schristos # if 1
759*fd82c4c4Schristos /* This function is defined as a macro on Mac OS X.  */
760*fd82c4c4Schristos #  if defined __cplusplus && defined GNULIB_NAMESPACE
761*fd82c4c4Schristos #   undef sigfillset
762*fd82c4c4Schristos #  endif
763*fd82c4c4Schristos # else
764*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
765*fd82c4c4Schristos # endif
766*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set));
767*fd82c4c4Schristos _GL_CXXALIASWARN (sigfillset);
768*fd82c4c4Schristos 
769*fd82c4c4Schristos /* Return the set of those blocked signals that are pending.  */
770*fd82c4c4Schristos # if !1
771*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
772*fd82c4c4Schristos # endif
773*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set));
774*fd82c4c4Schristos _GL_CXXALIASWARN (sigpending);
775*fd82c4c4Schristos 
776*fd82c4c4Schristos /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
777*fd82c4c4Schristos    Then, if SET is not NULL, affect the current set of blocked signals by
778*fd82c4c4Schristos    combining it with *SET as indicated in OPERATION.
779*fd82c4c4Schristos    In this implementation, you are not allowed to change a signal handler
780*fd82c4c4Schristos    while the signal is blocked.  */
781*fd82c4c4Schristos # if !1
782*fd82c4c4Schristos #  define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
783*fd82c4c4Schristos #  define SIG_SETMASK 1  /* blocked_set = *set; */
784*fd82c4c4Schristos #  define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
785*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigprocmask, int,
786*fd82c4c4Schristos                   (int operation,
787*fd82c4c4Schristos                    const sigset_t *restrict set,
788*fd82c4c4Schristos                    sigset_t *restrict old_set));
789*fd82c4c4Schristos # endif
790*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigprocmask, int,
791*fd82c4c4Schristos                   (int operation,
792*fd82c4c4Schristos                    const sigset_t *restrict set,
793*fd82c4c4Schristos                    sigset_t *restrict old_set));
794*fd82c4c4Schristos _GL_CXXALIASWARN (sigprocmask);
795*fd82c4c4Schristos 
796*fd82c4c4Schristos /* Install the handler FUNC for signal SIG, and return the previous
797*fd82c4c4Schristos    handler.  */
798*fd82c4c4Schristos # ifdef __cplusplus
799*fd82c4c4Schristos extern "C" {
800*fd82c4c4Schristos # endif
801*fd82c4c4Schristos # if !GNULIB_defined_function_taking_int_returning_void_t
802*fd82c4c4Schristos typedef void (*_gl_function_taking_int_returning_void_t) (int);
803*fd82c4c4Schristos #  define GNULIB_defined_function_taking_int_returning_void_t 1
804*fd82c4c4Schristos # endif
805*fd82c4c4Schristos # ifdef __cplusplus
806*fd82c4c4Schristos }
807*fd82c4c4Schristos # endif
808*fd82c4c4Schristos # if !1
809*fd82c4c4Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
810*fd82c4c4Schristos #   define signal rpl_signal
811*fd82c4c4Schristos #  endif
812*fd82c4c4Schristos _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t,
813*fd82c4c4Schristos                   (int sig, _gl_function_taking_int_returning_void_t func));
814*fd82c4c4Schristos _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
815*fd82c4c4Schristos                   (int sig, _gl_function_taking_int_returning_void_t func));
816*fd82c4c4Schristos # else
817*fd82c4c4Schristos /* On OpenBSD, the declaration of 'signal' may not be present at this point,
818*fd82c4c4Schristos    because it occurs in <sys/signal.h>, not <signal.h> directly.  */
819*fd82c4c4Schristos #  if defined __OpenBSD__
820*fd82c4c4Schristos _GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t,
821*fd82c4c4Schristos                   (int sig, _gl_function_taking_int_returning_void_t func));
822*fd82c4c4Schristos #  endif
823*fd82c4c4Schristos _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
824*fd82c4c4Schristos                   (int sig, _gl_function_taking_int_returning_void_t func));
825*fd82c4c4Schristos # endif
826*fd82c4c4Schristos # if __GLIBC__ >= 2
827*fd82c4c4Schristos _GL_CXXALIASWARN (signal);
828*fd82c4c4Schristos # endif
829*fd82c4c4Schristos 
830*fd82c4c4Schristos # if !1 && GNULIB_defined_SIGPIPE
831*fd82c4c4Schristos /* Raise signal SIGPIPE.  */
832*fd82c4c4Schristos _GL_EXTERN_C int _gl_raise_SIGPIPE (void);
833*fd82c4c4Schristos # endif
834*fd82c4c4Schristos 
835*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
836*fd82c4c4Schristos # undef sigaddset
837*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGADDSET
838*fd82c4c4Schristos _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - "
839*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
840*fd82c4c4Schristos # endif
841*fd82c4c4Schristos # undef sigdelset
842*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGDELSET
843*fd82c4c4Schristos _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - "
844*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
845*fd82c4c4Schristos # endif
846*fd82c4c4Schristos # undef sigemptyset
847*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGEMPTYSET
848*fd82c4c4Schristos _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - "
849*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
850*fd82c4c4Schristos # endif
851*fd82c4c4Schristos # undef sigfillset
852*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGFILLSET
853*fd82c4c4Schristos _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - "
854*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
855*fd82c4c4Schristos # endif
856*fd82c4c4Schristos # undef sigismember
857*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGISMEMBER
858*fd82c4c4Schristos _GL_WARN_ON_USE (sigismember, "sigismember is unportable - "
859*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
860*fd82c4c4Schristos # endif
861*fd82c4c4Schristos # undef sigpending
862*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGPENDING
863*fd82c4c4Schristos _GL_WARN_ON_USE (sigpending, "sigpending is unportable - "
864*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
865*fd82c4c4Schristos # endif
866*fd82c4c4Schristos # undef sigprocmask
867*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGPROCMASK
868*fd82c4c4Schristos _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - "
869*fd82c4c4Schristos                  "use the gnulib module sigprocmask for portability");
870*fd82c4c4Schristos # endif
871*fd82c4c4Schristos #endif /* 0 */
872*fd82c4c4Schristos 
873*fd82c4c4Schristos 
874*fd82c4c4Schristos #if 0
875*fd82c4c4Schristos # if !1
876*fd82c4c4Schristos 
877*fd82c4c4Schristos #  if !1
878*fd82c4c4Schristos 
879*fd82c4c4Schristos #   if !GNULIB_defined_siginfo_types
880*fd82c4c4Schristos 
881*fd82c4c4Schristos /* Present to allow compilation, but unsupported by gnulib.  */
882*fd82c4c4Schristos union sigval
883*fd82c4c4Schristos {
884*fd82c4c4Schristos   int sival_int;
885*fd82c4c4Schristos   void *sival_ptr;
886*fd82c4c4Schristos };
887*fd82c4c4Schristos 
888*fd82c4c4Schristos /* Present to allow compilation, but unsupported by gnulib.  */
889*fd82c4c4Schristos struct siginfo_t
890*fd82c4c4Schristos {
891*fd82c4c4Schristos   int si_signo;
892*fd82c4c4Schristos   int si_code;
893*fd82c4c4Schristos   int si_errno;
894*fd82c4c4Schristos   pid_t si_pid;
895*fd82c4c4Schristos   uid_t si_uid;
896*fd82c4c4Schristos   void *si_addr;
897*fd82c4c4Schristos   int si_status;
898*fd82c4c4Schristos   long si_band;
899*fd82c4c4Schristos   union sigval si_value;
900*fd82c4c4Schristos };
901*fd82c4c4Schristos typedef struct siginfo_t siginfo_t;
902*fd82c4c4Schristos 
903*fd82c4c4Schristos #    define GNULIB_defined_siginfo_types 1
904*fd82c4c4Schristos #   endif
905*fd82c4c4Schristos 
906*fd82c4c4Schristos #  endif /* !1 */
907*fd82c4c4Schristos 
908*fd82c4c4Schristos /* We assume that platforms which lack the sigaction() function also lack
909*fd82c4c4Schristos    the 'struct sigaction' type, and vice versa.  */
910*fd82c4c4Schristos 
911*fd82c4c4Schristos #  if !GNULIB_defined_struct_sigaction
912*fd82c4c4Schristos 
913*fd82c4c4Schristos struct sigaction
914*fd82c4c4Schristos {
915*fd82c4c4Schristos   union
916*fd82c4c4Schristos   {
917*fd82c4c4Schristos     void (*_sa_handler) (int);
918*fd82c4c4Schristos     /* Present to allow compilation, but unsupported by gnulib.  POSIX
919*fd82c4c4Schristos        says that implementations may, but not must, make sa_sigaction
920*fd82c4c4Schristos        overlap with sa_handler, but we know of no implementation where
921*fd82c4c4Schristos        they do not overlap.  */
922*fd82c4c4Schristos     void (*_sa_sigaction) (int, siginfo_t *, void *);
923*fd82c4c4Schristos   } _sa_func;
924*fd82c4c4Schristos   sigset_t sa_mask;
925*fd82c4c4Schristos   /* Not all POSIX flags are supported.  */
926*fd82c4c4Schristos   int sa_flags;
927*fd82c4c4Schristos };
928*fd82c4c4Schristos #   define sa_handler _sa_func._sa_handler
929*fd82c4c4Schristos #   define sa_sigaction _sa_func._sa_sigaction
930*fd82c4c4Schristos /* Unsupported flags are not present.  */
931*fd82c4c4Schristos #   define SA_RESETHAND 1
932*fd82c4c4Schristos #   define SA_NODEFER 2
933*fd82c4c4Schristos #   define SA_RESTART 4
934*fd82c4c4Schristos 
935*fd82c4c4Schristos #   define GNULIB_defined_struct_sigaction 1
936*fd82c4c4Schristos #  endif
937*fd82c4c4Schristos 
938*fd82c4c4Schristos _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
939*fd82c4c4Schristos                                    struct sigaction *restrict));
940*fd82c4c4Schristos 
941*fd82c4c4Schristos # elif !1
942*fd82c4c4Schristos 
943*fd82c4c4Schristos #  define sa_sigaction sa_handler
944*fd82c4c4Schristos 
945*fd82c4c4Schristos # endif /* !1, !1 */
946*fd82c4c4Schristos 
947*fd82c4c4Schristos _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict,
948*fd82c4c4Schristos                                    struct sigaction *restrict));
949*fd82c4c4Schristos _GL_CXXALIASWARN (sigaction);
950*fd82c4c4Schristos 
951*fd82c4c4Schristos #elif defined GNULIB_POSIXCHECK
952*fd82c4c4Schristos # undef sigaction
953*fd82c4c4Schristos # if HAVE_RAW_DECL_SIGACTION
954*fd82c4c4Schristos _GL_WARN_ON_USE (sigaction, "sigaction is unportable - "
955*fd82c4c4Schristos                  "use the gnulib module sigaction for portability");
956*fd82c4c4Schristos # endif
957*fd82c4c4Schristos #endif
958*fd82c4c4Schristos 
959*fd82c4c4Schristos /* Some systems don't have SA_NODEFER.  */
960*fd82c4c4Schristos #ifndef SA_NODEFER
961*fd82c4c4Schristos # define SA_NODEFER 0
962*fd82c4c4Schristos #endif
963*fd82c4c4Schristos 
964*fd82c4c4Schristos 
965*fd82c4c4Schristos #endif /* _GL_SIGNAL_H */
966*fd82c4c4Schristos #endif /* _GL_SIGNAL_H */
967*fd82c4c4Schristos #endif
968