|
@@ -6,33 +6,27 @@
|
|
|
* Change Logs:
|
|
|
* Date Author Notes
|
|
|
* 2017-09-12 Bernard The first version
|
|
|
+ * 2021-07-21 Meco Man move to libc/common
|
|
|
*/
|
|
|
|
|
|
-#ifndef LIBC_SIGNAL_H__
|
|
|
-#define LIBC_SIGNAL_H__
|
|
|
+#ifndef __SYS_SIGNAL_H__
|
|
|
+#define __SYS_SIGNAL_H__
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
|
|
|
#include <stdint.h>
|
|
|
-#ifdef HAVE_CCONFIG_H
|
|
|
-#include <cconfig.h>
|
|
|
-#endif
|
|
|
|
|
|
-#ifndef HAVE_SIGVAL
|
|
|
/* Signal Generation and Delivery, P1003.1b-1993, p. 63
|
|
|
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
|
|
|
sigev_notify_attributes to the sigevent structure. */
|
|
|
-
|
|
|
union sigval
|
|
|
{
|
|
|
int sival_int; /* Integer signal value */
|
|
|
void *sival_ptr; /* Pointer signal value */
|
|
|
};
|
|
|
-#endif
|
|
|
|
|
|
-#ifndef HAVE_SIGEVENT
|
|
|
struct sigevent
|
|
|
{
|
|
|
int sigev_notify; /* Notification type */
|
|
@@ -42,9 +36,7 @@ struct sigevent
|
|
|
/* Notification function */
|
|
|
void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
|
|
|
};
|
|
|
-#endif
|
|
|
|
|
|
-#ifndef HAVE_SIGINFO
|
|
|
struct siginfo
|
|
|
{
|
|
|
uint16_t si_signo;
|
|
@@ -53,26 +45,37 @@ struct siginfo
|
|
|
union sigval si_value;
|
|
|
};
|
|
|
typedef struct siginfo siginfo_t;
|
|
|
-#endif
|
|
|
|
|
|
#define SI_USER 0x01 /* Signal sent by kill(). */
|
|
|
#define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
|
|
|
-#define SI_TIMER 0x03 /* Signal generated by expiration of a
|
|
|
- timer set by timer_settime(). */
|
|
|
-#define SI_ASYNCIO 0x04 /* Signal generated by completion of an
|
|
|
- asynchronous I/O request. */
|
|
|
-#define SI_MESGQ 0x05 /* Signal generated by arrival of a
|
|
|
- message on an empty message queue. */
|
|
|
-
|
|
|
-#if !defined(RT_USING_NEWLIB)
|
|
|
+#define SI_TIMER 0x03 /* Signal generated by expiration of a timer set by timer_settime(). */
|
|
|
+#define SI_ASYNCIO 0x04 /* Signal generated by completion of an asynchronous I/O request. */
|
|
|
+#define SI_MESGQ 0x05 /* Signal generated by arrival of a message on an empty message queue. */
|
|
|
+
|
|
|
typedef void (*_sig_func_ptr)(int);
|
|
|
typedef unsigned long sigset_t;
|
|
|
-#endif
|
|
|
|
|
|
-#include <signal.h>
|
|
|
+struct sigaction
|
|
|
+{
|
|
|
+ _sig_func_ptr sa_handler;
|
|
|
+ sigset_t sa_mask;
|
|
|
+ int sa_flags;
|
|
|
+};
|
|
|
|
|
|
-#ifdef __ARMCC_VERSION
|
|
|
+#define SIG_SETMASK 0 /* set mask with sigprocmask() */
|
|
|
+#define SIG_BLOCK 1 /* set of signals to block */
|
|
|
+#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
|
|
|
|
|
+#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
|
|
|
+#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
|
|
|
+#define sigemptyset(what) (*(what) = 0, 0)
|
|
|
+#define sigfillset(what) (*(what) = ~(0), 0)
|
|
|
+#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
|
|
|
+
|
|
|
+int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
|
|
|
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
|
|
+
|
|
|
+#ifdef __ARMCC_VERSION
|
|
|
#define SIGHUP 1
|
|
|
/* #define SIGINT 2 */
|
|
|
#define SIGQUIT 3
|
|
@@ -103,28 +106,9 @@ typedef unsigned long sigset_t;
|
|
|
#define SIGRTMAX 31
|
|
|
#define NSIG 32
|
|
|
|
|
|
-#define SIG_SETMASK 0 /* set mask with sigprocmask() */
|
|
|
-#define SIG_BLOCK 1 /* set of signals to block */
|
|
|
-#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
|
|
-
|
|
|
-struct sigaction
|
|
|
-{
|
|
|
- _sig_func_ptr sa_handler;
|
|
|
- sigset_t sa_mask;
|
|
|
- int sa_flags;
|
|
|
-};
|
|
|
-
|
|
|
-#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
|
|
|
-#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
|
|
|
-#define sigemptyset(what) (*(what) = 0, 0)
|
|
|
-#define sigfillset(what) (*(what) = ~(0), 0)
|
|
|
-#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
|
|
|
-
|
|
|
-int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
|
|
|
-int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
|
|
+#include <signal.h>
|
|
|
|
|
|
#elif defined(__IAR_SYSTEMS_ICC__)
|
|
|
-
|
|
|
#define SIGHUP 1
|
|
|
#define SIGINT 2
|
|
|
#define SIGQUIT 3
|
|
@@ -155,25 +139,51 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
|
|
|
#define SIGRTMAX 31
|
|
|
#define NSIG 32
|
|
|
|
|
|
-#define SIG_SETMASK 0 /* set mask with sigprocmask() */
|
|
|
-#define SIG_BLOCK 1 /* set of signals to block */
|
|
|
-#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
|
|
-
|
|
|
-struct sigaction
|
|
|
-{
|
|
|
- _sig_func_ptr sa_handler;
|
|
|
- sigset_t sa_mask;
|
|
|
- int sa_flags;
|
|
|
-};
|
|
|
+#include <signal.h>
|
|
|
|
|
|
-#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
|
|
|
-#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
|
|
|
-#define sigemptyset(what) (*(what) = 0, 0)
|
|
|
-#define sigfillset(what) (*(what) = ~(0), 0)
|
|
|
-#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
|
|
|
+#elif defined(__GNUC__)
|
|
|
+#define SIGHUP 1 /* hangup */
|
|
|
+#define SIGINT 2 /* interrupt */
|
|
|
+#define SIGQUIT 3 /* quit */
|
|
|
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
|
|
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
|
|
+#define SIGIOT 6 /* IOT instruction */
|
|
|
+#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
|
|
|
+#define SIGEMT 7 /* EMT instruction */
|
|
|
+#define SIGFPE 8 /* floating point exception */
|
|
|
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
|
|
+#define SIGBUS 10 /* bus error */
|
|
|
+#define SIGSEGV 11 /* segmentation violation */
|
|
|
+#define SIGSYS 12 /* bad argument to system call */
|
|
|
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
|
|
+#define SIGALRM 14 /* alarm clock */
|
|
|
+#define SIGTERM 15 /* software termination signal from kill */
|
|
|
+#define SIGURG 16 /* urgent condition on IO channel */
|
|
|
+#define SIGSTOP 17 /* sendable stop signal not from tty */
|
|
|
+#define SIGTSTP 18 /* stop signal from tty */
|
|
|
+#define SIGCONT 19 /* continue a stopped process */
|
|
|
+#define SIGCHLD 20 /* to parent on child stop or exit */
|
|
|
+#define SIGCLD 20 /* System V name for SIGCHLD */
|
|
|
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
|
|
|
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
|
|
|
+#define SIGIO 23 /* input/output possible signal */
|
|
|
+#define SIGPOLL SIGIO /* System V name for SIGIO */
|
|
|
+#define SIGXCPU 24 /* exceeded CPU time limit */
|
|
|
+#define SIGXFSZ 25 /* exceeded file size limit */
|
|
|
+#define SIGVTALRM 26 /* virtual time alarm */
|
|
|
+#define SIGPROF 27 /* profiling time alarm */
|
|
|
+#define SIGWINCH 28 /* window changed */
|
|
|
+#define SIGLOST 29 /* resource lost (eg, record-lock lost) */
|
|
|
+#define SIGUSR1 30 /* user defined signal 1 */
|
|
|
+#define SIGUSR2 31 /* user defined signal 2 */
|
|
|
+#define NSIG 32 /* signal 0 implied */
|
|
|
+
|
|
|
+#ifndef _SIGNAL_H_
|
|
|
+/* Some applications take advantage of the fact that <sys/signal.h>
|
|
|
+ * and <signal.h> are equivalent in glibc. Allow for that here. */
|
|
|
+#include <signal.h>
|
|
|
+#endif
|
|
|
|
|
|
-int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
|
|
|
-int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
|
|
#endif
|
|
|
|
|
|
#ifdef __cplusplus
|