Home | History | Annotate | Line # | Download | only in import
signal.in.h revision 1.1
      1  1.1  christos /* A GNU-like <signal.h>.
      2  1.1  christos 
      3  1.1  christos    Copyright (C) 2006-2020 Free Software Foundation, Inc.
      4  1.1  christos 
      5  1.1  christos    This program is free software: you can redistribute it and/or modify
      6  1.1  christos    it under the terms of the GNU General Public License as published by
      7  1.1  christos    the Free Software Foundation; either version 3 of the License, or
      8  1.1  christos    (at your option) any later version.
      9  1.1  christos 
     10  1.1  christos    This program is distributed in the hope that it will be useful,
     11  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  christos    GNU General Public License for more details.
     14  1.1  christos 
     15  1.1  christos    You should have received a copy of the GNU General Public License
     16  1.1  christos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
     17  1.1  christos 
     18  1.1  christos #if __GNUC__ >= 3
     19  1.1  christos @PRAGMA_SYSTEM_HEADER@
     20  1.1  christos #endif
     21  1.1  christos @PRAGMA_COLUMNS@
     22  1.1  christos 
     23  1.1  christos #if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
     24  1.1  christos /* Special invocation convention:
     25  1.1  christos    - Inside glibc header files.
     26  1.1  christos    - On glibc systems we have a sequence of nested includes
     27  1.1  christos      <signal.h> -> <ucontext.h> -> <signal.h>.
     28  1.1  christos      In this situation, the functions are not yet declared, therefore we cannot
     29  1.1  christos      provide the C++ aliases.
     30  1.1  christos    - On glibc systems with GCC 4.3 we have a sequence of nested includes
     31  1.1  christos      <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>.
     32  1.1  christos      In this situation, some of the functions are not yet declared, therefore
     33  1.1  christos      we cannot provide the C++ aliases.  */
     34  1.1  christos 
     35  1.1  christos # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
     36  1.1  christos 
     37  1.1  christos #else
     38  1.1  christos /* Normal invocation convention.  */
     39  1.1  christos 
     40  1.1  christos #ifndef _@GUARD_PREFIX@_SIGNAL_H
     41  1.1  christos 
     42  1.1  christos #define _GL_ALREADY_INCLUDING_SIGNAL_H
     43  1.1  christos 
     44  1.1  christos /* Define pid_t, uid_t.
     45  1.1  christos    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
     46  1.1  christos    On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes
     47  1.1  christos    us; so include <sys/types.h> now, before the second inclusion guard.  */
     48  1.1  christos #include <sys/types.h>
     49  1.1  christos 
     50  1.1  christos /* The include_next requires a split double-inclusion guard.  */
     51  1.1  christos #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
     52  1.1  christos 
     53  1.1  christos #undef _GL_ALREADY_INCLUDING_SIGNAL_H
     54  1.1  christos 
     55  1.1  christos #ifndef _@GUARD_PREFIX@_SIGNAL_H
     56  1.1  christos #define _@GUARD_PREFIX@_SIGNAL_H
     57  1.1  christos 
     58  1.1  christos /* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android
     59  1.1  christos    declare pthread_sigmask in <pthread.h>, not in <signal.h>.
     60  1.1  christos    But avoid namespace pollution on glibc systems.*/
     61  1.1  christos #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
     62  1.1  christos     && ((defined __APPLE__ && defined __MACH__) \
     63  1.1  christos         || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \
     64  1.1  christos         || defined __sun || defined __ANDROID__) \
     65  1.1  christos     && ! defined __GLIBC__
     66  1.1  christos # include <pthread.h>
     67  1.1  christos #endif
     68  1.1  christos 
     69  1.1  christos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
     70  1.1  christos 
     71  1.1  christos /* The definition of _GL_ARG_NONNULL is copied here.  */
     72  1.1  christos 
     73  1.1  christos /* The definition of _GL_WARN_ON_USE is copied here.  */
     74  1.1  christos 
     75  1.1  christos /* On AIX, sig_atomic_t already includes volatile.  C99 requires that
     76  1.1  christos    'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
     77  1.1  christos    Hence, redefine this to a non-volatile type as needed.  */
     78  1.1  christos #if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
     79  1.1  christos # if !GNULIB_defined_sig_atomic_t
     80  1.1  christos typedef int rpl_sig_atomic_t;
     81  1.1  christos #  undef sig_atomic_t
     82  1.1  christos #  define sig_atomic_t rpl_sig_atomic_t
     83  1.1  christos #  define GNULIB_defined_sig_atomic_t 1
     84  1.1  christos # endif
     85  1.1  christos #endif
     86  1.1  christos 
     87  1.1  christos /* A set or mask of signals.  */
     88  1.1  christos #if !@HAVE_SIGSET_T@
     89  1.1  christos # if !GNULIB_defined_sigset_t
     90  1.1  christos typedef unsigned int sigset_t;
     91  1.1  christos #  define GNULIB_defined_sigset_t 1
     92  1.1  christos # endif
     93  1.1  christos #endif
     94  1.1  christos 
     95  1.1  christos /* Define sighandler_t, the type of signal handlers.  A GNU extension.  */
     96  1.1  christos #if !@HAVE_SIGHANDLER_T@
     97  1.1  christos # ifdef __cplusplus
     98  1.1  christos extern "C" {
     99  1.1  christos # endif
    100  1.1  christos # if !GNULIB_defined_sighandler_t
    101  1.1  christos typedef void (*sighandler_t) (int);
    102  1.1  christos #  define GNULIB_defined_sighandler_t 1
    103  1.1  christos # endif
    104  1.1  christos # ifdef __cplusplus
    105  1.1  christos }
    106  1.1  christos # endif
    107  1.1  christos #endif
    108  1.1  christos 
    109  1.1  christos 
    110  1.1  christos #if @GNULIB_SIGNAL_H_SIGPIPE@
    111  1.1  christos # ifndef SIGPIPE
    112  1.1  christos /* Define SIGPIPE to a value that does not overlap with other signals.  */
    113  1.1  christos #  define SIGPIPE 13
    114  1.1  christos #  define GNULIB_defined_SIGPIPE 1
    115  1.1  christos /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
    116  1.1  christos    'write', 'stdio'.  */
    117  1.1  christos # endif
    118  1.1  christos #endif
    119  1.1  christos 
    120  1.1  christos 
    121  1.1  christos /* Maximum signal number + 1.  */
    122  1.1  christos #ifndef NSIG
    123  1.1  christos # if defined __TANDEM
    124  1.1  christos #  define NSIG 32
    125  1.1  christos # endif
    126  1.1  christos #endif
    127  1.1  christos 
    128  1.1  christos 
    129  1.1  christos #if @GNULIB_PTHREAD_SIGMASK@
    130  1.1  christos # if @REPLACE_PTHREAD_SIGMASK@
    131  1.1  christos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    132  1.1  christos #   undef pthread_sigmask
    133  1.1  christos #   define pthread_sigmask rpl_pthread_sigmask
    134  1.1  christos #  endif
    135  1.1  christos _GL_FUNCDECL_RPL (pthread_sigmask, int,
    136  1.1  christos                   (int how,
    137  1.1  christos                    const sigset_t *restrict new_mask,
    138  1.1  christos                    sigset_t *restrict old_mask));
    139  1.1  christos _GL_CXXALIAS_RPL (pthread_sigmask, int,
    140  1.1  christos                   (int how,
    141  1.1  christos                    const sigset_t *restrict new_mask,
    142  1.1  christos                    sigset_t *restrict old_mask));
    143  1.1  christos # else
    144  1.1  christos #  if !(@HAVE_PTHREAD_SIGMASK@ || defined pthread_sigmask)
    145  1.1  christos _GL_FUNCDECL_SYS (pthread_sigmask, int,
    146  1.1  christos                   (int how,
    147  1.1  christos                    const sigset_t *restrict new_mask,
    148  1.1  christos                    sigset_t *restrict old_mask));
    149  1.1  christos #  endif
    150  1.1  christos _GL_CXXALIAS_SYS (pthread_sigmask, int,
    151  1.1  christos                   (int how,
    152  1.1  christos                    const sigset_t *restrict new_mask,
    153  1.1  christos                    sigset_t *restrict old_mask));
    154  1.1  christos # endif
    155  1.1  christos # if __GLIBC__ >= 2
    156  1.1  christos _GL_CXXALIASWARN (pthread_sigmask);
    157  1.1  christos # endif
    158  1.1  christos #elif defined GNULIB_POSIXCHECK
    159  1.1  christos # undef pthread_sigmask
    160  1.1  christos # if HAVE_RAW_DECL_PTHREAD_SIGMASK
    161  1.1  christos _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
    162  1.1  christos                  "use gnulib module pthread_sigmask for portability");
    163  1.1  christos # endif
    164  1.1  christos #endif
    165  1.1  christos 
    166  1.1  christos 
    167  1.1  christos #if @GNULIB_RAISE@
    168  1.1  christos # if @REPLACE_RAISE@
    169  1.1  christos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    170  1.1  christos #   undef raise
    171  1.1  christos #   define raise rpl_raise
    172  1.1  christos #  endif
    173  1.1  christos _GL_FUNCDECL_RPL (raise, int, (int sig));
    174  1.1  christos _GL_CXXALIAS_RPL (raise, int, (int sig));
    175  1.1  christos # else
    176  1.1  christos #  if !@HAVE_RAISE@
    177  1.1  christos _GL_FUNCDECL_SYS (raise, int, (int sig));
    178  1.1  christos #  endif
    179  1.1  christos _GL_CXXALIAS_SYS (raise, int, (int sig));
    180  1.1  christos # endif
    181  1.1  christos # if __GLIBC__ >= 2
    182  1.1  christos _GL_CXXALIASWARN (raise);
    183  1.1  christos # endif
    184  1.1  christos #elif defined GNULIB_POSIXCHECK
    185  1.1  christos # undef raise
    186  1.1  christos /* Assume raise is always declared.  */
    187  1.1  christos _GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
    188  1.1  christos                  "use gnulib module raise for portability");
    189  1.1  christos #endif
    190  1.1  christos 
    191  1.1  christos 
    192  1.1  christos #if @GNULIB_SIGPROCMASK@
    193  1.1  christos # if !@HAVE_POSIX_SIGNALBLOCKING@
    194  1.1  christos 
    195  1.1  christos #  ifndef GNULIB_defined_signal_blocking
    196  1.1  christos #   define GNULIB_defined_signal_blocking 1
    197  1.1  christos #  endif
    198  1.1  christos 
    199  1.1  christos /* Maximum signal number + 1.  */
    200  1.1  christos #  ifndef NSIG
    201  1.1  christos #   define NSIG 32
    202  1.1  christos #  endif
    203  1.1  christos 
    204  1.1  christos /* This code supports only 32 signals.  */
    205  1.1  christos #  if !GNULIB_defined_verify_NSIG_constraint
    206  1.1  christos typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
    207  1.1  christos #   define GNULIB_defined_verify_NSIG_constraint 1
    208  1.1  christos #  endif
    209  1.1  christos 
    210  1.1  christos # endif
    211  1.1  christos 
    212  1.1  christos /* When also using extern inline, suppress the use of static inline in
    213  1.1  christos    standard headers of problematic Apple configurations, as Libc at
    214  1.1  christos    least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
    215  1.1  christos    <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
    216  1.1  christos    Perhaps Apple will fix this some day.  */
    217  1.1  christos #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
    218  1.1  christos      && (defined __i386__ || defined __x86_64__))
    219  1.1  christos # undef sigaddset
    220  1.1  christos # undef sigdelset
    221  1.1  christos # undef sigemptyset
    222  1.1  christos # undef sigfillset
    223  1.1  christos # undef sigismember
    224  1.1  christos #endif
    225  1.1  christos 
    226  1.1  christos /* Test whether a given signal is contained in a signal set.  */
    227  1.1  christos # if @HAVE_POSIX_SIGNALBLOCKING@
    228  1.1  christos /* This function is defined as a macro on Mac OS X.  */
    229  1.1  christos #  if defined __cplusplus && defined GNULIB_NAMESPACE
    230  1.1  christos #   undef sigismember
    231  1.1  christos #  endif
    232  1.1  christos # else
    233  1.1  christos _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
    234  1.1  christos                                     _GL_ARG_NONNULL ((1)));
    235  1.1  christos # endif
    236  1.1  christos _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig));
    237  1.1  christos _GL_CXXALIASWARN (sigismember);
    238  1.1  christos 
    239  1.1  christos /* Initialize a signal set to the empty set.  */
    240  1.1  christos # if @HAVE_POSIX_SIGNALBLOCKING@
    241  1.1  christos /* This function is defined as a macro on Mac OS X.  */
    242  1.1  christos #  if defined __cplusplus && defined GNULIB_NAMESPACE
    243  1.1  christos #   undef sigemptyset
    244  1.1  christos #  endif
    245  1.1  christos # else
    246  1.1  christos _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
    247  1.1  christos # endif
    248  1.1  christos _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set));
    249  1.1  christos _GL_CXXALIASWARN (sigemptyset);
    250  1.1  christos 
    251  1.1  christos /* Add a signal to a signal set.  */
    252  1.1  christos # if @HAVE_POSIX_SIGNALBLOCKING@
    253  1.1  christos /* This function is defined as a macro on Mac OS X.  */
    254  1.1  christos #  if defined __cplusplus && defined GNULIB_NAMESPACE
    255  1.1  christos #   undef sigaddset
    256  1.1  christos #  endif
    257  1.1  christos # else
    258  1.1  christos _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
    259  1.1  christos                                   _GL_ARG_NONNULL ((1)));
    260  1.1  christos # endif
    261  1.1  christos _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig));
    262  1.1  christos _GL_CXXALIASWARN (sigaddset);
    263  1.1  christos 
    264  1.1  christos /* Remove a signal from a signal set.  */
    265  1.1  christos # if @HAVE_POSIX_SIGNALBLOCKING@
    266  1.1  christos /* This function is defined as a macro on Mac OS X.  */
    267  1.1  christos #  if defined __cplusplus && defined GNULIB_NAMESPACE
    268  1.1  christos #   undef sigdelset
    269  1.1  christos #  endif
    270  1.1  christos # else
    271  1.1  christos _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
    272  1.1  christos                                   _GL_ARG_NONNULL ((1)));
    273  1.1  christos # endif
    274  1.1  christos _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig));
    275  1.1  christos _GL_CXXALIASWARN (sigdelset);
    276  1.1  christos 
    277  1.1  christos /* Fill a signal set with all possible signals.  */
    278  1.1  christos # if @HAVE_POSIX_SIGNALBLOCKING@
    279  1.1  christos /* This function is defined as a macro on Mac OS X.  */
    280  1.1  christos #  if defined __cplusplus && defined GNULIB_NAMESPACE
    281  1.1  christos #   undef sigfillset
    282  1.1  christos #  endif
    283  1.1  christos # else
    284  1.1  christos _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
    285  1.1  christos # endif
    286  1.1  christos _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set));
    287  1.1  christos _GL_CXXALIASWARN (sigfillset);
    288  1.1  christos 
    289  1.1  christos /* Return the set of those blocked signals that are pending.  */
    290  1.1  christos # if !@HAVE_POSIX_SIGNALBLOCKING@
    291  1.1  christos _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
    292  1.1  christos # endif
    293  1.1  christos _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set));
    294  1.1  christos _GL_CXXALIASWARN (sigpending);
    295  1.1  christos 
    296  1.1  christos /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
    297  1.1  christos    Then, if SET is not NULL, affect the current set of blocked signals by
    298  1.1  christos    combining it with *SET as indicated in OPERATION.
    299  1.1  christos    In this implementation, you are not allowed to change a signal handler
    300  1.1  christos    while the signal is blocked.  */
    301  1.1  christos # if !@HAVE_POSIX_SIGNALBLOCKING@
    302  1.1  christos #  define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
    303  1.1  christos #  define SIG_SETMASK 1  /* blocked_set = *set; */
    304  1.1  christos #  define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
    305  1.1  christos _GL_FUNCDECL_SYS (sigprocmask, int,
    306  1.1  christos                   (int operation,
    307  1.1  christos                    const sigset_t *restrict set,
    308  1.1  christos                    sigset_t *restrict old_set));
    309  1.1  christos # endif
    310  1.1  christos _GL_CXXALIAS_SYS (sigprocmask, int,
    311  1.1  christos                   (int operation,
    312  1.1  christos                    const sigset_t *restrict set,
    313  1.1  christos                    sigset_t *restrict old_set));
    314  1.1  christos _GL_CXXALIASWARN (sigprocmask);
    315  1.1  christos 
    316  1.1  christos /* Install the handler FUNC for signal SIG, and return the previous
    317  1.1  christos    handler.  */
    318  1.1  christos # ifdef __cplusplus
    319  1.1  christos extern "C" {
    320  1.1  christos # endif
    321  1.1  christos # if !GNULIB_defined_function_taking_int_returning_void_t
    322  1.1  christos typedef void (*_gl_function_taking_int_returning_void_t) (int);
    323  1.1  christos #  define GNULIB_defined_function_taking_int_returning_void_t 1
    324  1.1  christos # endif
    325  1.1  christos # ifdef __cplusplus
    326  1.1  christos }
    327  1.1  christos # endif
    328  1.1  christos # if !@HAVE_POSIX_SIGNALBLOCKING@
    329  1.1  christos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    330  1.1  christos #   define signal rpl_signal
    331  1.1  christos #  endif
    332  1.1  christos _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t,
    333  1.1  christos                   (int sig, _gl_function_taking_int_returning_void_t func));
    334  1.1  christos _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
    335  1.1  christos                   (int sig, _gl_function_taking_int_returning_void_t func));
    336  1.1  christos # else
    337  1.1  christos /* On OpenBSD, the declaration of 'signal' may not be present at this point,
    338  1.1  christos    because it occurs in <sys/signal.h>, not <signal.h> directly.  */
    339  1.1  christos #  if defined __OpenBSD__
    340  1.1  christos _GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t,
    341  1.1  christos                   (int sig, _gl_function_taking_int_returning_void_t func));
    342  1.1  christos #  endif
    343  1.1  christos _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
    344  1.1  christos                   (int sig, _gl_function_taking_int_returning_void_t func));
    345  1.1  christos # endif
    346  1.1  christos # if __GLIBC__ >= 2
    347  1.1  christos _GL_CXXALIASWARN (signal);
    348  1.1  christos # endif
    349  1.1  christos 
    350  1.1  christos # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE
    351  1.1  christos /* Raise signal SIGPIPE.  */
    352  1.1  christos _GL_EXTERN_C int _gl_raise_SIGPIPE (void);
    353  1.1  christos # endif
    354  1.1  christos 
    355  1.1  christos #elif defined GNULIB_POSIXCHECK
    356  1.1  christos # undef sigaddset
    357  1.1  christos # if HAVE_RAW_DECL_SIGADDSET
    358  1.1  christos _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - "
    359  1.1  christos                  "use the gnulib module sigprocmask for portability");
    360  1.1  christos # endif
    361  1.1  christos # undef sigdelset
    362  1.1  christos # if HAVE_RAW_DECL_SIGDELSET
    363  1.1  christos _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - "
    364  1.1  christos                  "use the gnulib module sigprocmask for portability");
    365  1.1  christos # endif
    366  1.1  christos # undef sigemptyset
    367  1.1  christos # if HAVE_RAW_DECL_SIGEMPTYSET
    368  1.1  christos _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - "
    369  1.1  christos                  "use the gnulib module sigprocmask for portability");
    370  1.1  christos # endif
    371  1.1  christos # undef sigfillset
    372  1.1  christos # if HAVE_RAW_DECL_SIGFILLSET
    373  1.1  christos _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - "
    374  1.1  christos                  "use the gnulib module sigprocmask for portability");
    375  1.1  christos # endif
    376  1.1  christos # undef sigismember
    377  1.1  christos # if HAVE_RAW_DECL_SIGISMEMBER
    378  1.1  christos _GL_WARN_ON_USE (sigismember, "sigismember is unportable - "
    379  1.1  christos                  "use the gnulib module sigprocmask for portability");
    380  1.1  christos # endif
    381  1.1  christos # undef sigpending
    382  1.1  christos # if HAVE_RAW_DECL_SIGPENDING
    383  1.1  christos _GL_WARN_ON_USE (sigpending, "sigpending is unportable - "
    384  1.1  christos                  "use the gnulib module sigprocmask for portability");
    385  1.1  christos # endif
    386  1.1  christos # undef sigprocmask
    387  1.1  christos # if HAVE_RAW_DECL_SIGPROCMASK
    388  1.1  christos _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - "
    389  1.1  christos                  "use the gnulib module sigprocmask for portability");
    390  1.1  christos # endif
    391  1.1  christos #endif /* @GNULIB_SIGPROCMASK@ */
    392  1.1  christos 
    393  1.1  christos 
    394  1.1  christos #if @GNULIB_SIGACTION@
    395  1.1  christos # if !@HAVE_SIGACTION@
    396  1.1  christos 
    397  1.1  christos #  if !@HAVE_SIGINFO_T@
    398  1.1  christos 
    399  1.1  christos #   if !GNULIB_defined_siginfo_types
    400  1.1  christos 
    401  1.1  christos /* Present to allow compilation, but unsupported by gnulib.  */
    402  1.1  christos union sigval
    403  1.1  christos {
    404  1.1  christos   int sival_int;
    405  1.1  christos   void *sival_ptr;
    406  1.1  christos };
    407  1.1  christos 
    408  1.1  christos /* Present to allow compilation, but unsupported by gnulib.  */
    409  1.1  christos struct siginfo_t
    410  1.1  christos {
    411  1.1  christos   int si_signo;
    412  1.1  christos   int si_code;
    413  1.1  christos   int si_errno;
    414  1.1  christos   pid_t si_pid;
    415  1.1  christos   uid_t si_uid;
    416  1.1  christos   void *si_addr;
    417  1.1  christos   int si_status;
    418  1.1  christos   long si_band;
    419  1.1  christos   union sigval si_value;
    420  1.1  christos };
    421  1.1  christos typedef struct siginfo_t siginfo_t;
    422  1.1  christos 
    423  1.1  christos #    define GNULIB_defined_siginfo_types 1
    424  1.1  christos #   endif
    425  1.1  christos 
    426  1.1  christos #  endif /* !@HAVE_SIGINFO_T@ */
    427  1.1  christos 
    428  1.1  christos /* We assume that platforms which lack the sigaction() function also lack
    429  1.1  christos    the 'struct sigaction' type, and vice versa.  */
    430  1.1  christos 
    431  1.1  christos #  if !GNULIB_defined_struct_sigaction
    432  1.1  christos 
    433  1.1  christos struct sigaction
    434  1.1  christos {
    435  1.1  christos   union
    436  1.1  christos   {
    437  1.1  christos     void (*_sa_handler) (int);
    438  1.1  christos     /* Present to allow compilation, but unsupported by gnulib.  POSIX
    439  1.1  christos        says that implementations may, but not must, make sa_sigaction
    440  1.1  christos        overlap with sa_handler, but we know of no implementation where
    441  1.1  christos        they do not overlap.  */
    442  1.1  christos     void (*_sa_sigaction) (int, siginfo_t *, void *);
    443  1.1  christos   } _sa_func;
    444  1.1  christos   sigset_t sa_mask;
    445  1.1  christos   /* Not all POSIX flags are supported.  */
    446  1.1  christos   int sa_flags;
    447  1.1  christos };
    448  1.1  christos #   define sa_handler _sa_func._sa_handler
    449  1.1  christos #   define sa_sigaction _sa_func._sa_sigaction
    450  1.1  christos /* Unsupported flags are not present.  */
    451  1.1  christos #   define SA_RESETHAND 1
    452  1.1  christos #   define SA_NODEFER 2
    453  1.1  christos #   define SA_RESTART 4
    454  1.1  christos 
    455  1.1  christos #   define GNULIB_defined_struct_sigaction 1
    456  1.1  christos #  endif
    457  1.1  christos 
    458  1.1  christos _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
    459  1.1  christos                                    struct sigaction *restrict));
    460  1.1  christos 
    461  1.1  christos # elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
    462  1.1  christos 
    463  1.1  christos #  define sa_sigaction sa_handler
    464  1.1  christos 
    465  1.1  christos # endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
    466  1.1  christos 
    467  1.1  christos _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict,
    468  1.1  christos                                    struct sigaction *restrict));
    469  1.1  christos _GL_CXXALIASWARN (sigaction);
    470  1.1  christos 
    471  1.1  christos #elif defined GNULIB_POSIXCHECK
    472  1.1  christos # undef sigaction
    473  1.1  christos # if HAVE_RAW_DECL_SIGACTION
    474  1.1  christos _GL_WARN_ON_USE (sigaction, "sigaction is unportable - "
    475  1.1  christos                  "use the gnulib module sigaction for portability");
    476  1.1  christos # endif
    477  1.1  christos #endif
    478  1.1  christos 
    479  1.1  christos /* Some systems don't have SA_NODEFER.  */
    480  1.1  christos #ifndef SA_NODEFER
    481  1.1  christos # define SA_NODEFER 0
    482  1.1  christos #endif
    483  1.1  christos 
    484  1.1  christos 
    485  1.1  christos #endif /* _@GUARD_PREFIX@_SIGNAL_H */
    486  1.1  christos #endif /* _@GUARD_PREFIX@_SIGNAL_H */
    487  1.1  christos #endif
    488