2017-10-15 22:30:05 +08:00
|
|
|
/*
|
2018-09-14 22:37:43 +08:00
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
2017-10-15 22:30:05 +08:00
|
|
|
*
|
2018-09-14 22:37:43 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-10-15 22:30:05 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2017-09-12 Bernard The first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBC_SIGNAL_H__
|
|
|
|
#define LIBC_SIGNAL_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-05-14 21:37:11 +08:00
|
|
|
#ifdef HAVE_CCONFIG_H
|
|
|
|
#include <cconfig.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_SIGVAL
|
2017-12-31 14:48:54 +08:00
|
|
|
/* 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. */
|
|
|
|
|
2019-12-16 13:59:46 +08:00
|
|
|
union sigval
|
2017-10-15 22:30:05 +08:00
|
|
|
{
|
|
|
|
int sival_int; /* Integer signal value */
|
|
|
|
void *sival_ptr; /* Pointer signal value */
|
|
|
|
};
|
2018-05-14 21:37:11 +08:00
|
|
|
#endif
|
2017-10-15 22:30:05 +08:00
|
|
|
|
2018-05-14 21:37:11 +08:00
|
|
|
#ifndef HAVE_SIGEVENT
|
2017-12-31 14:48:54 +08:00
|
|
|
struct sigevent
|
|
|
|
{
|
|
|
|
int sigev_notify; /* Notification type */
|
|
|
|
int sigev_signo; /* Signal number */
|
|
|
|
union sigval sigev_value; /* Signal value */
|
|
|
|
void (*sigev_notify_function)( union sigval );
|
|
|
|
/* Notification function */
|
|
|
|
void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
|
|
|
|
};
|
2018-05-14 21:37:11 +08:00
|
|
|
#endif
|
2017-12-31 14:48:54 +08:00
|
|
|
|
2018-05-14 21:37:11 +08:00
|
|
|
#ifndef HAVE_SIGINFO
|
2017-10-15 22:30:05 +08:00
|
|
|
struct siginfo
|
|
|
|
{
|
2018-05-14 21:37:11 +08:00
|
|
|
rt_uint16_t si_signo;
|
|
|
|
rt_uint16_t si_code;
|
2017-10-15 22:30:05 +08:00
|
|
|
|
|
|
|
union sigval si_value;
|
|
|
|
};
|
|
|
|
typedef struct siginfo siginfo_t;
|
2018-03-01 13:36:22 +08:00
|
|
|
#endif
|
2017-10-15 22:30:05 +08:00
|
|
|
|
2018-03-01 13:36:22 +08:00
|
|
|
#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
|
2017-10-15 22:30:05 +08:00
|
|
|
timer set by timer_settime(). */
|
2018-03-01 13:36:22 +08:00
|
|
|
#define SI_ASYNCIO 0x04 /* Signal generated by completion of an
|
|
|
|
asynchronous I/O request. */
|
|
|
|
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
|
2017-10-15 22:30:05 +08:00
|
|
|
message on an empty message queue. */
|
|
|
|
|
|
|
|
#ifdef RT_USING_NEWLIB
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#endif
|
|
|
|
|
2018-09-23 12:08:44 +08:00
|
|
|
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
2017-10-15 22:30:05 +08:00
|
|
|
#include <signal.h>
|
|
|
|
typedef unsigned long sigset_t;
|
|
|
|
|
|
|
|
#define SIGHUP 1
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGINT 2 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGQUIT 3
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGILL 4 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGTRAP 5
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGABRT 6 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGEMT 7
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGFPE 8 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGKILL 9
|
|
|
|
#define SIGBUS 10
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGSEGV 11 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGSYS 12
|
|
|
|
#define SIGPIPE 13
|
|
|
|
#define SIGALRM 14
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGTERM 15 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGURG 16
|
|
|
|
#define SIGSTOP 17
|
|
|
|
#define SIGTSTP 18
|
|
|
|
#define SIGCONT 19
|
|
|
|
#define SIGCHLD 20
|
|
|
|
#define SIGTTIN 21
|
|
|
|
#define SIGTTOU 22
|
|
|
|
#define SIGPOLL 23
|
|
|
|
#define SIGWINCH 24
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGUSR1 25 */
|
|
|
|
/* #define SIGUSR2 26 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGRTMIN 27
|
|
|
|
#define SIGRTMAX 31
|
|
|
|
#define NSIG 32
|
|
|
|
|
2018-03-01 13:36:22 +08:00
|
|
|
#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 */
|
2017-10-15 22:30:05 +08:00
|
|
|
|
|
|
|
typedef void (*_sig_func_ptr)(int);
|
|
|
|
|
2019-12-16 13:59:46 +08:00
|
|
|
struct sigaction
|
2017-10-15 22:30:05 +08:00
|
|
|
{
|
2018-03-01 13:36:22 +08:00
|
|
|
_sig_func_ptr sa_handler;
|
|
|
|
sigset_t sa_mask;
|
|
|
|
int sa_flags;
|
2017-10-15 22:30:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#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);
|
|
|
|
|
|
|
|
#elif defined(__IAR_SYSTEMS_ICC__)
|
|
|
|
#include <signal.h>
|
|
|
|
typedef unsigned long sigset_t;
|
|
|
|
|
|
|
|
#define SIGHUP 1
|
|
|
|
#define SIGINT 2
|
|
|
|
#define SIGQUIT 3
|
|
|
|
#define SIGILL 4
|
|
|
|
#define SIGTRAP 5
|
2018-11-10 16:58:07 +08:00
|
|
|
/* #define SIGABRT 6 */
|
2017-10-15 22:30:05 +08:00
|
|
|
#define SIGEMT 7
|
|
|
|
#define SIGFPE 8
|
|
|
|
#define SIGKILL 9
|
|
|
|
#define SIGBUS 10
|
|
|
|
#define SIGSEGV 11
|
|
|
|
#define SIGSYS 12
|
|
|
|
#define SIGPIPE 13
|
|
|
|
#define SIGALRM 14
|
|
|
|
#define SIGTERM 15
|
|
|
|
#define SIGURG 16
|
|
|
|
#define SIGSTOP 17
|
|
|
|
#define SIGTSTP 18
|
|
|
|
#define SIGCONT 19
|
|
|
|
#define SIGCHLD 20
|
|
|
|
#define SIGTTIN 21
|
|
|
|
#define SIGTTOU 22
|
|
|
|
#define SIGPOLL 23
|
|
|
|
#define SIGWINCH 24
|
|
|
|
#define SIGUSR1 25
|
|
|
|
#define SIGUSR2 26
|
|
|
|
#define SIGRTMIN 27
|
|
|
|
#define SIGRTMAX 31
|
|
|
|
#define NSIG 32
|
|
|
|
|
2018-03-01 13:36:22 +08:00
|
|
|
#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 */
|
2017-10-15 22:30:05 +08:00
|
|
|
|
|
|
|
typedef void (*_sig_func_ptr)(int);
|
|
|
|
|
2019-12-16 13:59:46 +08:00
|
|
|
struct sigaction
|
2017-10-15 22:30:05 +08:00
|
|
|
{
|
2018-03-01 13:36:22 +08:00
|
|
|
_sig_func_ptr sa_handler;
|
|
|
|
sigset_t sa_mask;
|
|
|
|
int sa_flags;
|
2017-10-15 22:30:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#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);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|