xref: /aosp_15_r20/external/llvm-libc/include/llvm-libc-macros/linux/signal-macros.h (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- Definition of Linux signal number macros --------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_MACROS_LINUX_SIGNAL_MACROS_H
10 #define LLVM_LIBC_MACROS_LINUX_SIGNAL_MACROS_H
11 
12 #define SIGHUP 1
13 #define SIGINT 2
14 #define SIGQUIT 3
15 #define SIGILL 4
16 #define SIGTRAP 5
17 #define SIGABRT 6
18 #define SIGIOT 6
19 #define SIGBUS 7
20 #define SIGFPE 8
21 #define SIGKILL 9
22 #define SIGUSR1 10
23 #define SIGSEGV 11
24 #define SIGUSR2 12
25 #define SIGPIPE 13
26 #define SIGALRM 14
27 #define SIGTERM 15
28 #define SIGSTKFLT 16
29 #define SIGCHLD 17
30 #define SIGCONT 18
31 #define SIGSTOP 19
32 #define SIGTSTP 20
33 #define SIGTTIN 21
34 #define SIGTTOU 22
35 #define SIGURG 23
36 #define SIGXCPU 24
37 #define SIGXFSZ 25
38 #define SIGVTALRM 26
39 #define SIGPROF 27
40 #define SIGWINCH 28
41 #define SIGIO 29
42 #define SIGPOLL SIGIO
43 #define SIGPWR 30
44 #define SIGSYS 31
45 
46 // Max signal number
47 #define NSIG 64
48 
49 // SIGRTMIN is current set to the minimum usable from user mode programs. If
50 // the libc itself uses some of these signal numbers for private operations,
51 // then it has to be adjusted in future to reflect that.
52 #define SIGRTMIN 32
53 
54 #define SIGRTMAX NSIG
55 
56 // The kernel sigset is stored as an array of long values. Each bit of this
57 // array corresponds to a signal, adjusted by 1. That is, bit 0 corresponds
58 // to signal number 1, bit 1 corresponds to signal number 2 and so on. The
59 // below macro denotes the size of that array (in number of long words and
60 // not bytes).
61 #define __NSIGSET_WORDS (NSIG / (sizeof(unsigned long) * 8))
62 
63 #define SIG_BLOCK 0   // For blocking signals
64 #define SIG_UNBLOCK 1 // For unblocking signals
65 #define SIG_SETMASK 2 // For setting signal mask
66 
67 // Flag values to be used for setting sigaction.sa_flags.
68 #define SA_NOCLDSTOP 0x00000001
69 #define SA_NOCLDWAIT 0x00000002
70 #define SA_SIGINFO 0x00000004
71 #define SA_RESTART 0x10000000
72 #define SA_RESTORER 0x04000000
73 #define SA_ONSTACK 0x08000000
74 
75 // Signal stack flags
76 #define SS_ONSTACK 0x1
77 #define SS_DISABLE 0x2
78 
79 #if defined(__x86_64__) || defined(__i386__) || defined(__riscv)
80 #define MINSIGSTKSZ 2048
81 #define SIGSTKSZ 8192
82 #elif defined(__aarch64__)
83 #define MINSIGSTKSZ 5120
84 #define SIGSTKSZ 16384
85 #else
86 #error "Signal stack sizes not defined for your platform."
87 #endif
88 
89 #define SIG_DFL ((__sighandler_t)0)
90 #define SIG_IGN ((__sighandler_t)1)
91 #define SIG_ERR ((__sighandler_t)-1)
92 
93 // SIGCHLD si_codes
94 #define CLD_EXITED 1    // child has exited
95 #define CLD_KILLED 2    // child was killed
96 #define CLD_DUMPED 3    // child terminated abnormally
97 #define CLD_TRAPPED 4   // traced child has trapped
98 #define CLD_STOPPED 5   // child has stopped
99 #define CLD_CONTINUED 6 // stopped child has continued
100 
101 #endif // LLVM_LIBC_MACROS_LINUX_SIGNAL_MACROS_H
102