signal.h revision 51794
11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1991, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 131539Srgrimes * 3. All advertising materials mentioning features or use of this software 141539Srgrimes * must display the following acknowledgement: 151539Srgrimes * This product includes software developed by the University of 161539Srgrimes * California, Berkeley and its contributors. 171539Srgrimes * 4. Neither the name of the University nor the names of its contributors 181539Srgrimes * may be used to endorse or promote products derived from this software 191539Srgrimes * without specific prior written permission. 201539Srgrimes * 211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311539Srgrimes * SUCH DAMAGE. 321539Srgrimes * 331539Srgrimes * @(#)signal.h 8.3 (Berkeley) 3/30/94 3451794Smarcel * 3551794Smarcel * $FreeBSD: head/include/signal.h 51794 1999-09-29 15:18:46Z marcel $ 361539Srgrimes */ 371539Srgrimes 389343Sbde#ifndef _SIGNAL_H_ 399343Sbde#define _SIGNAL_H_ 401539Srgrimes 411539Srgrimes#include <sys/cdefs.h> 4234925Sdufault#include <sys/_posix.h> 4338119Sdfr#include <machine/ansi.h> 441539Srgrimes#include <sys/signal.h> 4551794Smarcel#include <sys/time.h> 461539Srgrimes 471539Srgrimes#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 481539Srgrimesextern __const char *__const sys_signame[NSIG]; 491539Srgrimesextern __const char *__const sys_siglist[NSIG]; 5047289Speterextern __const int sys_nsig; 511539Srgrimes#endif 521539Srgrimes 531539Srgrimes__BEGIN_DECLS 541539Srgrimesint raise __P((int)); 551539Srgrimes#ifndef _ANSI_SOURCE 569343Sbdeint kill __P((_BSD_PID_T_, int)); 571539Srgrimesint sigaction __P((int, const struct sigaction *, struct sigaction *)); 581539Srgrimesint sigaddset __P((sigset_t *, int)); 591539Srgrimesint sigdelset __P((sigset_t *, int)); 601539Srgrimesint sigemptyset __P((sigset_t *)); 611539Srgrimesint sigfillset __P((sigset_t *)); 621539Srgrimesint sigismember __P((const sigset_t *, int)); 631539Srgrimesint sigpending __P((sigset_t *)); 641539Srgrimesint sigprocmask __P((int, const sigset_t *, sigset_t *)); 651539Srgrimesint sigsuspend __P((const sigset_t *)); 6638538Sjbint sigwait __P((const sigset_t *, int *)); 6734319Sdufault 6834319Sdufault 6934925Sdufault#ifdef _P1003_1B_VISIBLE 7034319Sdufault 7134319Sdufault__BEGIN_DECLS 7234030Sdufaultint sigqueue __P((_BSD_PID_T_, int, const union sigval)); 7351794Smarcelint sigtimedwait __P((const sigset_t *, siginfo_t *, const struct timespec *)); 7434319Sdufaultint sigwaitinfo __P((const sigset_t *, siginfo_t *)); 7534319Sdufault__END_DECLS 7634319Sdufault 7734030Sdufault#endif 781539Srgrimes#ifndef _POSIX_SOURCE 799343Sbdeint killpg __P((_BSD_PID_T_, int)); 8051794Smarcelint sigaltstack __P((const stack_t *, stack_t *)); 811539Srgrimesint sigblock __P((int)); 821539Srgrimesint siginterrupt __P((int, int)); 831539Srgrimesint sigpause __P((int)); 8451794Smarcelint sigreturn __P((ucontext_t *)); 851539Srgrimesint sigsetmask __P((int)); 861539Srgrimesint sigstack __P((const struct sigstack *, struct sigstack *)); 871539Srgrimesint sigvec __P((int, struct sigvec *, struct sigvec *)); 881539Srgrimesvoid psignal __P((unsigned int, const char *)); 899343Sbde#endif /* !_POSIX_SOURCE */ 909343Sbde#endif /* !_ANSI_SOURCE */ 911539Srgrimes__END_DECLS 921539Srgrimes 939343Sbde#ifndef _ANSI_SOURCE 941539Srgrimes/* List definitions after function declarations, or Reiser cpp gets upset. */ 9551794Smarcelextern __inline int sigaddset(sigset_t *set, int signo) 9651794Smarcel{ 9751794Smarcel 9851794Smarcel if (signo <= 0 || signo > _SIG_MAXSIG) { 9951794Smarcel /* errno = EINVAL; */ 10051794Smarcel return (-1); 10151794Smarcel } 10251794Smarcel set->__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo); 10351794Smarcel return (0); 10451794Smarcel} 10551794Smarcel 10651794Smarcelextern __inline int sigdelset(sigset_t *set, int signo) 10751794Smarcel{ 10851794Smarcel 10951794Smarcel if (signo <= 0 || signo > _SIG_MAXSIG) { 11051794Smarcel /* errno = EINVAL; */ 11151794Smarcel return (-1); 11251794Smarcel } 11351794Smarcel set->__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo); 11451794Smarcel return (0); 11551794Smarcel} 11651794Smarcel 11751794Smarcelextern __inline int sigemptyset(sigset_t *set) 11851794Smarcel{ 11951794Smarcel int i; 12051794Smarcel 12151794Smarcel for (i = 0; i < _SIG_WORDS; i++) 12251794Smarcel set->__bits[i] = 0; 12351794Smarcel return (0); 12451794Smarcel} 12551794Smarcel 12651794Smarcelextern __inline int sigfillset(sigset_t *set) 12751794Smarcel{ 12851794Smarcel int i; 12951794Smarcel 13051794Smarcel for (i = 0; i < _SIG_WORDS; i++) 13151794Smarcel set->__bits[i] = ~(unsigned int)0; 13251794Smarcel return (0); 13351794Smarcel} 13451794Smarcel 13551794Smarcelextern __inline int sigismember(__const sigset_t *set, int signo) 13651794Smarcel{ 13751794Smarcel 13851794Smarcel if (signo <= 0 || signo > _SIG_MAXSIG) { 13951794Smarcel /* errno = EINVAL; */ 14051794Smarcel return (-1); 14151794Smarcel } 14251794Smarcel return ((set->__bits[_SIG_WORD(signo)] & _SIG_BIT(signo)) ? 1 : 0); 14351794Smarcel} 1449343Sbde#endif /* !_ANSI_SOURCE */ 1451539Srgrimes 1469343Sbde#endif /* !_SIGNAL_H_ */ 147