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