1 /*
2 Copyright (C) 2001, 2004, 2005 Axis Communications AB.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8 
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 
12 2. Neither the name of Axis Communications nor the names of its
13 contributors may be used to endorse or promote products derived
14 from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
17 AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
20 COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28  */
29 /* This file is to be kept in sync (well, reasonably so, it's quite
30    different) with newlib/libc/include/sys/signal.h on which it is
31    based, except values used or returned by syscalls must be those of
32    the Linux/CRIS kernel.  */
33 
34 /* sys/signal.h */
35 
36 #ifndef _SYS_SIGNAL_H
37 #define _SYS_SIGNAL_H
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #include "_ansi.h"
43 #include <sys/features.h>
44 #include <sys/types.h>
45 
46 typedef unsigned long sigset_t;
47 
48 /* Adjusted to linux, has unused sa_restorer field and unsigned long
49    sa_flags; relatively unimportant though.  */
50 /* Type of a signal handler.  */
51 typedef void (*__sighandler_t)(int);
52 
53 /* The type used in newlib sources.  */
54 typedef __sighandler_t _sig_func_ptr;
55 
56 struct sigaction {
57 	__sighandler_t sa_handler;
58 	sigset_t sa_mask;
59 	unsigned long sa_flags;
60 	void (*sa_restorer)(void);
61 };
62 
63 /* Adjusted to glibc; other values.  */
64 #define SA_NOCLDSTOP 1	/* only value supported now for sa_flags */
65 
66 #if __POSIX_VISIBLE
67 #define SIG_SETMASK 2	/* set mask with sigprocmask() */
68 #define SIG_BLOCK 0	/* set of signals to block */
69 #define SIG_UNBLOCK 1	/* set of signals to, well, unblock */
70 
71 int sigprocmask (int __how, const sigset_t *__a, sigset_t *__b);
72 #endif	/* __POSIX_VISIBLE */
73 
74 #ifdef _LIBC
75 int _kill (pid_t, int);
76 #endif
77 
78 #if __POSIX_VISIBLE
79 
80 int kill (pid_t, int);
81 int sigaddset (sigset_t *, const int);
82 int sigdelset (sigset_t *, const int);
83 int sigismember (const sigset_t *, int);
84 int sigfillset (sigset_t *);
85 int sigemptyset (sigset_t *);
86 
87 /* These depend upon the type of sigset_t, which right now
88    is always a long.. They're in the POSIX namespace, but
89    are not ANSI. */
90 #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
91 #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
92 #define sigemptyset(what)   (*(what) = 0, 0)
93 #define sigfillset(what)    (*(what) = ~(0), 0)
94 #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
95 
96 #endif	/* __POSIX_VISIBLE */
97 
98 /* Using __MISC_VISIBLE until POSIX Issue 8 is officially released */
99 #if __MISC_VISIBLE
100 
101 /* POSIX Issue 8 adds sig2str() and str2sig() */
102 
103 #define SIG2STR_MAX 17	/* (sizeof("RTMAX+") + sizeof("4294967295") - 1) */
104 
105 int sig2str(int, char *);
106 int str2sig(const char *__restrict, int *__restrict);
107 
108 #endif /* __MISC_VISIBLE */
109 
110 #define SIGHUP		 1
111 #define SIGINT		 2
112 #define SIGQUIT		 3
113 #define SIGILL		 4
114 #define SIGTRAP		 5
115 #define SIGABRT		 6
116 #define SIGIOT		 6
117 #define SIGBUS		 7
118 #define SIGFPE		 8
119 #define SIGKILL		 9
120 #define SIGUSR1		10
121 #define SIGSEGV		11
122 #define SIGUSR2		12
123 #define SIGPIPE		13
124 #define SIGALRM		14
125 #define SIGTERM		15
126 #define SIGSTKFLT	16
127 #define SIGCHLD		17
128 #define SIGCONT		18
129 #define SIGSTOP		19
130 #define SIGTSTP		20
131 #define SIGTTIN		21
132 #define SIGTTOU		22
133 #define SIGURG		23
134 #define SIGXCPU		24
135 #define SIGXFSZ		25
136 #define SIGVTALRM	26
137 #define SIGPROF		27
138 #define SIGWINCH	28
139 #define SIGIO		29
140 #define SIGPOLL		SIGIO
141 #define SIGPWR		30
142 #define	NSIG 31
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 #ifndef _SIGNAL_H_
148 /* Some applications take advantage of the fact that <sys/signal.h>
149  * and <signal.h> are equivalent in glibc.  Allow for that here.  */
150 #include <signal.h>
151 #endif
152 #endif /* _SYS_SIGNAL_H */
153