1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
27 * generate signal features
30 #include "FEATURE/standards"
32 #define strsignal ______strsignal
45 #define elementsof(x) (sizeof(x)/sizeof(x[0]))
47 static struct _m_ map
[] =
51 "Abort", "ABRT", SIGABRT
,
55 "Asynchronous I/O", "AIO", SIGAIO
,
59 "Alarm call", "ALRM", SIGALRM
,
62 #define HAD_SIGAPOLLO 1
63 "Apollo", "APOLLO", SIGAPOLLO
,
67 "Bus error", "BUS", SIGBUS
,
71 "Child status change", "CHLD", SIGCHLD
,
75 "Death of child", "CLD", SIGCLD
,
79 "Stopped process continued", "CONT", SIGCONT
,
82 #define HAD_SIGDANGER 1
83 "System crash soon", "DANGER", SIGDANGER
,
86 #define HAD_SIGDEBUG 1
87 "Debug trap", "DEBUG", SIGDEBUG
,
91 "DIL trap", "DIL", SIGDIL
,
95 "EMT trap", "EMT", SIGEMT
,
99 "ERR trap", "ERR", SIGERR
,
102 #define HAD_SIGEXIT 1
103 "Exit", "EXIT", SIGEXIT
,
107 "Floating exception", "FPE", SIGFPE
,
110 #define HAD_SIGFREEZE 1
111 "CPR freeze", "FREEZE", SIGFREEZE
,
115 "Hangup", "HUP", SIGHUP
,
119 "Illegal instruction", "ILL", SIGILL
,
123 "Interrupt", "INT", SIGINT
,
127 "IO possible", "IO", SIGIO
,
131 "IOT trap", "IOT", SIGIOT
,
134 #define HAD_SIGKILL 1
135 "Killed", "KILL", SIGKILL
,
139 "Security label changed", "LAB", SIGLAB
,
142 #define HAD_SIGLOST 1
143 "Resources lost", "LOST", SIGLOST
,
147 "Thread event", "LWP", SIGLWP
,
150 #define HAD_SIGMIGRATE 1
151 "Migrate process", "MIGRATE", SIGMIGRATE
,
154 #define HAD_SIGPHONE 1
155 "Phone status change", "PHONE", SIGPHONE
,
158 #define HAD_SIGPIPE 1
159 "Broken pipe", "PIPE", SIGPIPE
,
162 #define HAD_SIGPOLL 1
163 "Poll event", "POLL", SIGPOLL
,
166 #define HAD_SIGPROF 1
167 "Profile timer alarm", "PROF", SIGPROF
,
171 "Power fail", "PWR", SIGPWR
,
174 #define HAD_SIGQUIT 1
175 "Quit", "QUIT", SIGQUIT
,
178 #define HAD_SIGSEGV 1
179 "Memory fault", "SEGV", SIGSEGV
,
182 #define HAD_SIGSOUND 1
183 "Sound completed", "SOUND", SIGSOUND
,
186 #define HAD_SIGSSTOP 1
187 "Sendable stop", "SSTOP", SIGSSTOP
,
191 "Stack overflow", "STKOV", 28,
194 #define HAD_SIGSTOP 1
195 "Stopped (signal)", "STOP", SIGSTOP
,
199 "Bad system call", "SYS", SIGSYS
,
202 #define HAD_SIGTERM 1
203 "Terminated", "TERM", SIGTERM
,
206 #define HAD_SIGTHAW 1
207 "CPR thaw", "THAW", SIGTHAW
,
210 #define HAD_SIGTINT 1
211 "Interrupt (terminal)", "TINT", SIGTINT
,
214 #define HAD_SIGTRAP 1
215 "Trace trap", "TRAP", SIGTRAP
,
218 #define HAD_SIGTSTP 1
219 "Stopped", "TSTP", SIGTSTP
,
222 #define HAD_SIGTTIN 1
223 "Stopped (tty input)", "TTIN", SIGTTIN
,
226 #define HAD_SIGTTOU 1
227 "Stopped (tty output)", "TTOU", SIGTTOU
,
231 "Urgent IO", "URG", SIGURG
,
234 #define HAD_SIGUSR1 1
235 "User signal 1", "USR1", SIGUSR1
,
238 #define HAD_SIGUSR2 1
239 "User signal 2", "USR2", SIGUSR2
,
242 #define HAD_SIGVTALRM 1
243 "Virtual timer alarm", "VTALRM", SIGVTALRM
,
246 #define HAD_SIGWAITING 1
247 "All threads blocked", "WAITING", SIGWAITING
,
250 #define HAD_SIGWINCH 1
251 "Window change", "WINCH", SIGWINCH
,
254 #define HAD_SIGWIND 1
255 "Window change", "WIND", SIGWIND
,
258 #define HAD_SIGWINDOW 1
259 "Window change", "WINDOW", SIGWINDOW
,
262 #define HAD_SIGXCPU 1
263 "CPU time limit", "XCPU", SIGXCPU
,
266 #define HAD_SIGXFSZ 1
267 "File size limit", "XFSZ", SIGXFSZ
,
269 #include "FEATURE/siglist"
273 #define RANGE_MIN (1<<14)
274 #define RANGE_MAX (1<<13)
275 #define RANGE_RT (1<<12)
277 #define RANGE_SIG (~(RANGE_MIN|RANGE_MAX|RANGE_RT))
279 static int mapindex
[1024];
282 extern char* strsignal(int);
298 for (i
= 0; map
[i
].name
; i
++)
299 if ((j
= map
[i
].value
) > 0 && j
< elementsof(mapindex
) && !mapindex
[j
])
312 if (j
>= elementsof(mapindex
))
313 j
= elementsof(mapindex
) - 1;
314 if (i
<= j
&& i
> 0 && i
< elementsof(mapindex
) && j
> 0 && j
< elementsof(mapindex
))
318 mapindex
[i
] = RANGE_MIN
| RANGE_RT
;
321 mapindex
[i
] = RANGE_RT
| n
++;
322 mapindex
[j
] = RANGE_MAX
| RANGE_RT
| n
;
325 printf("#pragma prototyped\n");
326 printf("#define SIG_MAX %d\n", k
);
328 printf("static const char* const sig_name[] =\n");
330 for (i
= 0; i
<= k
; i
++)
331 if (!(j
= mapindex
[i
]))
332 printf(" \"%d\",\n", i
);
333 else if (j
& RANGE_RT
)
336 printf(" \"RTMIN\",\n");
337 else if (j
& RANGE_MAX
)
338 printf(" \"RTMAX\",\n");
343 printf(" \"RTMAX-%d\",\n", n
- m
);
345 printf(" \"RTMIN+%d\",\n", m
);
349 printf(" \"%s\",\n", map
[j
].name
);
353 printf("static const char* const sig_text[] =\n");
355 for (i
= 0; i
<= k
; i
++)
356 if (!(j
= mapindex
[i
]))
357 printf(" \"Signal %d\",\n", i
);
358 else if (j
& RANGE_RT
)
359 printf(" \"Realtime priority %d%s\",\n", j
& RANGE_SIG
, (j
& RANGE_MIN
) ? " (lo)" : (j
& RANGE_MAX
) ? " (hi)" : "");
360 else if (map
[j
].text
)
361 printf(" \"%s\",\n", map
[j
].text
);
363 else if (s
= strsignal(i
))
364 printf(" \"%s\",\n", s
);
367 printf(" \"Signal %d\",\n", i
);