Debian Codegraph @

gnulib-tests/test-signal-h.c

raw
1 /* Test of <signal.h> substitute.
2 Copyright (C) 2009-2025 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 /* Written by Eric Blake <[email protected]>, 2009. */
18
19 #include <config.h>
20
21 #include <signal.h>
22
23 /* Check that SIG2STR_MAX is defined to a positive integer. */
24 static_assert (0 < SIG2STR_MAX);
25
26 /* Check for required types. */
27 struct
28 {
29 size_t a;
30 uid_t b;
31 volatile sig_atomic_t c;
32 sigset_t d;
33 pid_t e;
34 #if 0
35 /* Not guaranteed by gnulib. */
36 pthread_t f;
37 struct timespec g;
38 #endif
39 } s;
40
41 /* Check that NSIG is defined. */
42 int nsig = NSIG;
43
44 int
45 main (void)
46 {
47 switch (0)
48 {
49 /* The following are guaranteed by C. */
50 case 0:
51 case SIGABRT:
52 case SIGFPE:
53 case SIGILL:
54 case SIGINT:
55 case SIGSEGV:
56 case SIGTERM:
57 /* The following is guaranteed by gnulib. */
58 #if GNULIB_SIGPIPE || defined SIGPIPE
59 case SIGPIPE:
60 #endif
61 /* Ensure no conflict with other standardized names. */
62 #ifdef SIGALRM
63 case SIGALRM:
64 #endif
65 /* On Haiku, SIGBUS is mistakenly equal to SIGSEGV. */
66 #if defined SIGBUS && SIGBUS != SIGSEGV
67 case SIGBUS:
68 #endif
69 #ifdef SIGCHLD
70 case SIGCHLD:
71 #endif
72 #ifdef SIGCONT
73 case SIGCONT:
74 #endif
75 #ifdef SIGHUP
76 case SIGHUP:
77 #endif
78 #ifdef SIGKILL
79 case SIGKILL:
80 #endif
81 #ifdef SIGQUIT
82 case SIGQUIT:
83 #endif
84 #ifdef SIGSTOP
85 case SIGSTOP:
86 #endif
87 #ifdef SIGTSTP
88 case SIGTSTP:
89 #endif
90 #ifdef SIGTTIN
91 case SIGTTIN:
92 #endif
93 #ifdef SIGTTOU
94 case SIGTTOU:
95 #endif
96 #ifdef SIGUSR1
97 case SIGUSR1:
98 #endif
99 #ifdef SIGUSR2
100 case SIGUSR2:
101 #endif
102 #ifdef SIGSYS
103 case SIGSYS:
104 #endif
105 #ifdef SIGTRAP
106 case SIGTRAP:
107 #endif
108 #ifdef SIGURG
109 case SIGURG:
110 #endif
111 #ifdef SIGVTALRM
112 case SIGVTALRM:
113 #endif
114 #ifdef SIGXCPU
115 case SIGXCPU:
116 #endif
117 #ifdef SIGXFSZ
118 case SIGXFSZ:
119 #endif
120 /* SIGRTMIN and SIGRTMAX need not be compile-time constants. */
121 #if 0
122 # ifdef SIGRTMIN
123 case SIGRTMIN:
124 # endif
125 # ifdef SIGRTMAX
126 case SIGRTMAX:
127 # endif
128 #endif
129 ;
130 }
131 return s.a + s.b + s.c + s.e;
132 }