1 /*
2  * Copyright (c) 2018 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_INCLUDE_POSIX_SIGNAL_H_
7 #define ZEPHYR_INCLUDE_POSIX_SIGNAL_H_
8 
9 #include "posix_types.h"
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #ifdef CONFIG_POSIX_SIGNAL
16 #define SIGHUP    1  /**< Hangup */
17 #define SIGINT    2  /**< Interrupt */
18 #define SIGQUIT   3  /**< Quit */
19 #define SIGILL    4  /**< Illegal instruction */
20 #define SIGTRAP   5  /**< Trace/breakpoint trap */
21 #define SIGABRT   6  /**< Aborted */
22 #define SIGBUS    7  /**< Bus error */
23 #define SIGFPE    8  /**< Arithmetic exception */
24 #define SIGKILL   9  /**< Killed */
25 #define SIGUSR1   10 /**< User-defined signal 1 */
26 #define SIGSEGV   11 /**< Invalid memory reference */
27 #define SIGUSR2   12 /**< User-defined signal 2 */
28 #define SIGPIPE   13 /**< Broken pipe */
29 #define SIGALRM   14 /**< Alarm clock */
30 #define SIGTERM   15 /**< Terminated */
31 /* 16 not used */
32 #define SIGCHLD   17 /**< Child status changed */
33 #define SIGCONT   18 /**< Continued */
34 #define SIGSTOP   19 /**< Stop executing */
35 #define SIGTSTP   20 /**< Stopped */
36 #define SIGTTIN   21 /**< Stopped (read) */
37 #define SIGTTOU   22 /**< Stopped (write) */
38 #define SIGURG    23 /**< Urgent I/O condition */
39 #define SIGXCPU   24 /**< CPU time limit exceeded */
40 #define SIGXFSZ   25 /**< File size limit exceeded */
41 #define SIGVTALRM 26 /**< Virtual timer expired */
42 #define SIGPROF   27 /**< Profiling timer expired */
43 /* 28 not used */
44 #define SIGPOLL   29 /**< Pollable event occurred */
45 /* 30 not used */
46 #define SIGSYS    31 /**< Bad system call */
47 
48 #define SIGRTMIN 32
49 #define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX)
50 #define _NSIG (SIGRTMAX + 1)
51 
52 BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0);
53 
54 typedef struct {
55 	unsigned long sig[DIV_ROUND_UP(_NSIG, BITS_PER_LONG)];
56 } sigset_t;
57 
58 char *strsignal(int signum);
59 int sigemptyset(sigset_t *set);
60 int sigfillset(sigset_t *set);
61 int sigaddset(sigset_t *set, int signo);
62 int sigdelset(sigset_t *set, int signo);
63 int sigismember(const sigset_t *set, int signo);
64 #endif /* CONFIG_POSIX_SIGNAL */
65 
66 #ifndef SIGEV_NONE
67 #define SIGEV_NONE 1
68 #endif
69 
70 #ifndef SIGEV_SIGNAL
71 #define SIGEV_SIGNAL 2
72 #endif
73 
74 #ifndef SIGEV_THREAD
75 #define SIGEV_THREAD 3
76 #endif
77 
78 typedef int	sig_atomic_t;		/* Atomic entity type (ANSI) */
79 
80 union sigval {
81 	int sival_int;
82 	void *sival_ptr;
83 };
84 
85 struct sigevent {
86 	int sigev_notify;
87 	int sigev_signo;
88 	union sigval sigev_value;
89 	void (*sigev_notify_function)(union sigval val);
90 	pthread_attr_t *sigev_notify_attributes;
91 };
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ */
98