66 * Change Logs:
77 * Date Author Notes
88 * 2017-09-12 Bernard The first version
9+ * 2021-07-21 Meco Man move to libc/common
910 */
1011
11- #ifndef LIBC_SIGNAL_H__
12- #define LIBC_SIGNAL_H__
12+ #ifndef __SYS_SIGNAL_H__
13+ #define __SYS_SIGNAL_H__
1314
1415#ifdef __cplusplus
1516extern "C" {
1617#endif
1718
1819#include <stdint.h>
19- #ifdef HAVE_CCONFIG_H
20- #include <cconfig.h>
21- #endif
2220
23- #ifndef HAVE_SIGVAL
2421/* Signal Generation and Delivery, P1003.1b-1993, p. 63
2522 NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
2623 sigev_notify_attributes to the sigevent structure. */
27-
2824union sigval
2925{
3026 int sival_int ; /* Integer signal value */
3127 void * sival_ptr ; /* Pointer signal value */
3228};
33- #endif
3429
35- #ifndef HAVE_SIGEVENT
3630struct sigevent
3731{
3832 int sigev_notify ; /* Notification type */
@@ -42,9 +36,7 @@ struct sigevent
4236 /* Notification function */
4337 void * sigev_notify_attributes ; /* Notification Attributes, really pthread_attr_t */
4438};
45- #endif
4639
47- #ifndef HAVE_SIGINFO
4840struct siginfo
4941{
5042 uint16_t si_signo ;
@@ -53,26 +45,37 @@ struct siginfo
5345 union sigval si_value ;
5446};
5547typedef struct siginfo siginfo_t ;
56- #endif
5748
5849#define SI_USER 0x01 /* Signal sent by kill(). */
5950#define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
60- #define SI_TIMER 0x03 /* Signal generated by expiration of a
61- timer set by timer_settime(). */
62- #define SI_ASYNCIO 0x04 /* Signal generated by completion of an
63- asynchronous I/O request. */
64- #define SI_MESGQ 0x05 /* Signal generated by arrival of a
65- message on an empty message queue. */
66-
67- #if !defined(RT_USING_NEWLIB )
51+ #define SI_TIMER 0x03 /* Signal generated by expiration of a timer set by timer_settime(). */
52+ #define SI_ASYNCIO 0x04 /* Signal generated by completion of an asynchronous I/O request. */
53+ #define SI_MESGQ 0x05 /* Signal generated by arrival of a message on an empty message queue. */
54+
6855typedef void (* _sig_func_ptr )(int );
6956typedef unsigned long sigset_t ;
70- #endif
7157
72- #include <signal.h>
58+ struct sigaction
59+ {
60+ _sig_func_ptr sa_handler ;
61+ sigset_t sa_mask ;
62+ int sa_flags ;
63+ };
7364
74- #ifdef __ARMCC_VERSION
65+ #define SIG_SETMASK 0 /* set mask with sigprocmask() */
66+ #define SIG_BLOCK 1 /* set of signals to block */
67+ #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
7568
69+ #define sigaddset (what ,sig ) (*(what) |= (1<<(sig)), 0)
70+ #define sigdelset (what ,sig ) (*(what) &= ~(1<<(sig)), 0)
71+ #define sigemptyset (what ) (*(what) = 0, 0)
72+ #define sigfillset (what ) (*(what) = ~(0), 0)
73+ #define sigismember (what ,sig ) (((*(what)) & (1<<(sig))) != 0)
74+
75+ int sigprocmask (int how , const sigset_t * set , sigset_t * oset );
76+ int sigaction (int signum , const struct sigaction * act , struct sigaction * oldact );
77+
78+ #ifdef __ARMCC_VERSION
7679#define SIGHUP 1
7780/* #define SIGINT 2 */
7881#define SIGQUIT 3
@@ -103,28 +106,9 @@ typedef unsigned long sigset_t;
103106#define SIGRTMAX 31
104107#define NSIG 32
105108
106- #define SIG_SETMASK 0 /* set mask with sigprocmask() */
107- #define SIG_BLOCK 1 /* set of signals to block */
108- #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
109-
110- struct sigaction
111- {
112- _sig_func_ptr sa_handler ;
113- sigset_t sa_mask ;
114- int sa_flags ;
115- };
116-
117- #define sigaddset (what ,sig ) (*(what) |= (1<<(sig)), 0)
118- #define sigdelset (what ,sig ) (*(what) &= ~(1<<(sig)), 0)
119- #define sigemptyset (what ) (*(what) = 0, 0)
120- #define sigfillset (what ) (*(what) = ~(0), 0)
121- #define sigismember (what ,sig ) (((*(what)) & (1<<(sig))) != 0)
122-
123- int sigprocmask (int how , const sigset_t * set , sigset_t * oset );
124- int sigaction (int signum , const struct sigaction * act , struct sigaction * oldact );
109+ #include <signal.h>
125110
126111#elif defined(__IAR_SYSTEMS_ICC__ )
127-
128112#define SIGHUP 1
129113#define SIGINT 2
130114#define SIGQUIT 3
@@ -155,25 +139,51 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
155139#define SIGRTMAX 31
156140#define NSIG 32
157141
158- #define SIG_SETMASK 0 /* set mask with sigprocmask() */
159- #define SIG_BLOCK 1 /* set of signals to block */
160- #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
161-
162- struct sigaction
163- {
164- _sig_func_ptr sa_handler ;
165- sigset_t sa_mask ;
166- int sa_flags ;
167- };
142+ #include <signal.h>
168143
169- #define sigaddset (what ,sig ) (*(what) |= (1<<(sig)), 0)
170- #define sigdelset (what ,sig ) (*(what) &= ~(1<<(sig)), 0)
171- #define sigemptyset (what ) (*(what) = 0, 0)
172- #define sigfillset (what ) (*(what) = ~(0), 0)
173- #define sigismember (what ,sig ) (((*(what)) & (1<<(sig))) != 0)
144+ #elif defined(__GNUC__ )
145+ #define SIGHUP 1 /* hangup */
146+ #define SIGINT 2 /* interrupt */
147+ #define SIGQUIT 3 /* quit */
148+ #define SIGILL 4 /* illegal instruction (not reset when caught) */
149+ #define SIGTRAP 5 /* trace trap (not reset when caught) */
150+ #define SIGIOT 6 /* IOT instruction */
151+ #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
152+ #define SIGEMT 7 /* EMT instruction */
153+ #define SIGFPE 8 /* floating point exception */
154+ #define SIGKILL 9 /* kill (cannot be caught or ignored) */
155+ #define SIGBUS 10 /* bus error */
156+ #define SIGSEGV 11 /* segmentation violation */
157+ #define SIGSYS 12 /* bad argument to system call */
158+ #define SIGPIPE 13 /* write on a pipe with no one to read it */
159+ #define SIGALRM 14 /* alarm clock */
160+ #define SIGTERM 15 /* software termination signal from kill */
161+ #define SIGURG 16 /* urgent condition on IO channel */
162+ #define SIGSTOP 17 /* sendable stop signal not from tty */
163+ #define SIGTSTP 18 /* stop signal from tty */
164+ #define SIGCONT 19 /* continue a stopped process */
165+ #define SIGCHLD 20 /* to parent on child stop or exit */
166+ #define SIGCLD 20 /* System V name for SIGCHLD */
167+ #define SIGTTIN 21 /* to readers pgrp upon background tty read */
168+ #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
169+ #define SIGIO 23 /* input/output possible signal */
170+ #define SIGPOLL SIGIO /* System V name for SIGIO */
171+ #define SIGXCPU 24 /* exceeded CPU time limit */
172+ #define SIGXFSZ 25 /* exceeded file size limit */
173+ #define SIGVTALRM 26 /* virtual time alarm */
174+ #define SIGPROF 27 /* profiling time alarm */
175+ #define SIGWINCH 28 /* window changed */
176+ #define SIGLOST 29 /* resource lost (eg, record-lock lost) */
177+ #define SIGUSR1 30 /* user defined signal 1 */
178+ #define SIGUSR2 31 /* user defined signal 2 */
179+ #define NSIG 32 /* signal 0 implied */
180+
181+ #ifndef _SIGNAL_H_
182+ /* Some applications take advantage of the fact that <sys/signal.h>
183+ * and <signal.h> are equivalent in glibc. Allow for that here. */
184+ #include <signal.h>
185+ #endif
174186
175- int sigprocmask (int how , const sigset_t * set , sigset_t * oset );
176- int sigaction (int signum , const struct sigaction * act , struct sigaction * oldact );
177187#endif
178188
179189#ifdef __cplusplus
0 commit comments