File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libiconv / srclib / signal.in.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 22:57:48 2012 UTC (12 years, 4 months ago) by misho
Branches: libiconv, MAIN
CVS tags: v1_13_1, HEAD
libiconv

    1: /* A GNU-like <signal.h>.
    2: 
    3:    Copyright (C) 2006-2009 Free Software Foundation, Inc.
    4: 
    5:    This program is free software: you can redistribute it and/or modify
    6:    it under the terms of the GNU General Public License as published by
    7:    the Free Software Foundation; either version 3 of the License, or
    8:    (at your option) any later version.
    9: 
   10:    This program is distributed in the hope that it will be useful,
   11:    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13:    GNU General Public License for more details.
   14: 
   15:    You should have received a copy of the GNU General Public License
   16:    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
   17: 
   18: #if __GNUC__ >= 3
   19: @PRAGMA_SYSTEM_HEADER@
   20: #endif
   21: 
   22: #if defined __need_sig_atomic_t || defined __need_sigset_t
   23: /* Special invocation convention inside glibc header files.  */
   24: 
   25: # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
   26: 
   27: #else
   28: /* Normal invocation convention.  */
   29: 
   30: #ifndef _GL_SIGNAL_H
   31: 
   32: /* The include_next requires a split double-inclusion guard.  */
   33: #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
   34: 
   35: #ifndef _GL_SIGNAL_H
   36: #define _GL_SIGNAL_H
   37: 
   38: /* The definition of GL_LINK_WARNING is copied here.  */
   39: 
   40: /* Define pid_t, uid_t.
   41:    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
   42: #include <sys/types.h>
   43: 
   44: /* On AIX, sig_atomic_t already includes volatile.  C99 requires that
   45:    'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
   46:    Hence, redefine this to a non-volatile type as needed.  */
   47: #if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
   48: typedef int rpl_sig_atomic_t;
   49: # undef sig_atomic_t
   50: # define sig_atomic_t rpl_sig_atomic_t
   51: #endif
   52: 
   53: #ifdef __cplusplus
   54: extern "C" {
   55: #endif
   56: 
   57: 
   58: #if @GNULIB_SIGNAL_H_SIGPIPE@
   59: # ifndef SIGPIPE
   60: /* Define SIGPIPE to a value that does not overlap with other signals.  */
   61: #  define SIGPIPE 13
   62: #  define GNULIB_defined_SIGPIPE 1
   63: /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
   64:    'write', 'stdio'.  */
   65: # endif
   66: #endif
   67: 
   68: 
   69: #if !@HAVE_POSIX_SIGNALBLOCKING@
   70: 
   71: /* Maximum signal number + 1.  */
   72: # ifndef NSIG
   73: #  define NSIG 32
   74: # endif
   75: 
   76: /* This code supports only 32 signals.  */
   77: typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1];
   78: 
   79: /* A set or mask of signals.  */
   80: # if !@HAVE_SIGSET_T@
   81: typedef unsigned int sigset_t;
   82: # endif
   83: 
   84: /* Test whether a given signal is contained in a signal set.  */
   85: extern int sigismember (const sigset_t *set, int sig);
   86: 
   87: /* Initialize a signal set to the empty set.  */
   88: extern int sigemptyset (sigset_t *set);
   89: 
   90: /* Add a signal to a signal set.  */
   91: extern int sigaddset (sigset_t *set, int sig);
   92: 
   93: /* Remove a signal from a signal set.  */
   94: extern int sigdelset (sigset_t *set, int sig);
   95: 
   96: /* Fill a signal set with all possible signals.  */
   97: extern int sigfillset (sigset_t *set);
   98: 
   99: /* Return the set of those blocked signals that are pending.  */
  100: extern int sigpending (sigset_t *set);
  101: 
  102: /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
  103:    Then, if SET is not NULL, affect the current set of blocked signals by
  104:    combining it with *SET as indicated in OPERATION.
  105:    In this implementation, you are not allowed to change a signal handler
  106:    while the signal is blocked.  */
  107: # define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
  108: # define SIG_SETMASK 1  /* blocked_set = *set; */
  109: # define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
  110: extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set);
  111: 
  112: # define signal rpl_signal
  113: /* Install the handler FUNC for signal SIG, and return the previous
  114:    handler.  */
  115: extern void (*signal (int sig, void (*func) (int))) (int);
  116: 
  117: # if GNULIB_defined_SIGPIPE
  118: 
  119: /* Raise signal SIG.  */
  120: #  undef raise
  121: #  define raise rpl_raise
  122: extern int raise (int sig);
  123: 
  124: # endif
  125: 
  126: #endif /* !@HAVE_POSIX_SIGNALBLOCKING@ */
  127: 
  128: 
  129: #if !@HAVE_SIGACTION@
  130: 
  131: # if !@HAVE_SIGINFO_T@
  132: /* Present to allow compilation, but unsupported by gnulib.  */
  133: union sigval
  134: {
  135:   int sival_int;
  136:   void *sival_ptr;
  137: };
  138: 
  139: /* Present to allow compilation, but unsupported by gnulib.  */
  140: struct siginfo_t
  141: {
  142:   int si_signo;
  143:   int si_code;
  144:   int si_errno;
  145:   pid_t si_pid;
  146:   uid_t si_uid;
  147:   void *si_addr;
  148:   int si_status;
  149:   long si_band;
  150:   union sigval si_value;
  151: };
  152: typedef struct siginfo_t siginfo_t;
  153: # endif /* !@HAVE_SIGINFO_T@ */
  154: 
  155: /* We assume that platforms which lack the sigaction() function also lack
  156:    the 'struct sigaction' type, and vice versa.  */
  157: 
  158: struct sigaction
  159: {
  160:   union
  161:   {
  162:     void (*_sa_handler) (int);
  163:     /* Present to allow compilation, but unsupported by gnulib.  POSIX
  164:        says that implementations may, but not must, make sa_sigaction
  165:        overlap with sa_handler, but we know of no implementation where
  166:        they do not overlap.  */
  167:     void (*_sa_sigaction) (int, siginfo_t *, void *);
  168:   } _sa_func;
  169:   sigset_t sa_mask;
  170:   /* Not all POSIX flags are supported.  */
  171:   int sa_flags;
  172: };
  173: # define sa_handler _sa_func._sa_handler
  174: # define sa_sigaction _sa_func._sa_sigaction
  175: /* Unsupported flags are not present.  */
  176: # define SA_RESETHAND 1
  177: # define SA_NODEFER 2
  178: # define SA_RESTART 4
  179: 
  180: extern int sigaction (int, const struct sigaction *restrict,
  181:                       struct sigaction *restrict);
  182: 
  183: #elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
  184: 
  185: # define sa_sigaction sa_handler
  186: 
  187: #endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
  188: 
  189: 
  190: /* Some systems don't have SA_NODEFER.  */
  191: #ifndef SA_NODEFER
  192: # define SA_NODEFER 0
  193: #endif
  194: 
  195: 
  196: #ifdef __cplusplus
  197: }
  198: #endif
  199: 
  200: #endif /* _GL_SIGNAL_H */
  201: #endif /* _GL_SIGNAL_H */
  202: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>