Back to index

glibc  2.9
sigset.h
Go to the documentation of this file.
00001 /* __sig_atomic_t, __sigset_t, and related definitions.  Generic/BSD version.
00002    Copyright (C) 1991, 1992, 1994, 1996, 1997, 2007
00003    Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef       _SIGSET_H_types
00022 #define       _SIGSET_H_types      1
00023 
00024 typedef int __sig_atomic_t;
00025 
00026 /* A `sigset_t' has a bit for each signal.  */
00027 typedef unsigned long int __sigset_t;
00028 
00029 #endif
00030 
00031 
00032 /* We only want to define these functions if <signal.h> was actually
00033    included; otherwise we were included just to define the types.  Since we
00034    are namespace-clean, it wouldn't hurt to define extra macros.  But
00035    trouble can be caused by functions being defined (e.g., any global
00036    register vars declared later will cause compilation errors).  */
00037 
00038 #if !defined _SIGSET_H_fns && defined _SIGNAL_H
00039 #define _SIGSET_H_fns 1
00040 
00041 #ifndef _EXTERN_INLINE
00042 # define _EXTERN_INLINE __extern_inline
00043 #endif
00044 
00045 /* Return a mask that includes SIG only.  The cast to `sigset_t' avoids
00046    overflow if `sigset_t' is wider than `int'.  */
00047 #define       __sigmask(sig)       (((__sigset_t) 1) << ((sig) - 1))
00048 
00049 #define       __sigemptyset(set)   ((*(set) = (__sigset_t) 0), 0)
00050 #define       __sigfillset(set)    ((*(set) = ~(__sigset_t) 0), 0)
00051 
00052 #ifdef _GNU_SOURCE
00053 # define __sigisemptyset(set)      (*(set) == (__sigset_t) 0)
00054 # define __sigandset(dest, left, right) \
00055                             ((*(dest) = (*(left) & *(right))), 0)
00056 # define __sigorset(dest, left, right) \
00057                             ((*(dest) = (*(left) | *(right))), 0)
00058 #endif
00059 
00060 /* These functions needn't check for a bogus signal number -- error
00061    checking is done in the non __ versions.  */
00062 
00063 extern int __sigismember (__const __sigset_t *, int);
00064 extern int __sigaddset (__sigset_t *, int);
00065 extern int __sigdelset (__sigset_t *, int);
00066 
00067 #ifdef __USE_EXTERN_INLINES
00068 # define __SIGSETFN(NAME, BODY, CONST)                                      \
00069   _EXTERN_INLINE int                                                 \
00070   NAME (CONST __sigset_t *__set, int __sig)                                 \
00071   {                                                                  \
00072     __sigset_t __mask = __sigmask (__sig);                                  \
00073     return BODY;                                                     \
00074   }
00075 
00076 __SIGSETFN (__sigismember, (*__set & __mask) ? 1 : 0, __const)
00077 __SIGSETFN (__sigaddset, ((*__set |= __mask), 0), )
00078 __SIGSETFN (__sigdelset, ((*__set &= ~__mask), 0), )
00079 
00080 # undef __SIGSETFN
00081 #endif
00082 
00083 
00084 #endif /* ! _SIGSET_H_fns.  */