Improve the process for GNU tools
[minix3.git] / minix / usr.bin / trace / signal.awk
blob985f8d7e0e64ec1683fa05079214742abf1b40d0
1 # This one is a bit trickier than error.awk, because sys/signal.h is not as
2 # easy to parse. We currently assume that all (userland) signals are listed
3 # before the first reference to "_KERNEL", and anything else that looks like a
4 # signal definition (but isn't) is after that first reference.
6 BEGIN {
7 printf("/* This file is automatically generated by signal.awk */\n\n");
8 printf("#include \"inc.h\"\n\n");
9 printf("static const char *const signals[] = {\n");
11 /^#define/ {
12 name = $2;
13 if (!match(name, "SIG[^_]"))
14 next;
15 number = $3;
16 if (number < 0 || number == "SIGABRT")
17 next;
18 printf("\t[%s] = \"%s\",\n", name, name);
20 /_KERNEL/ {
21 exit;
23 END {
24 printf("};\n\n");
25 printf("const char *\nget_signal_name(int sig)\n{\n\n");
26 printf("\tif (sig >= 0 && (unsigned int)sig < __arraycount(signals) &&\n");
27 printf("\t signals[sig] != NULL)\n");
28 printf("\t\treturn signals[sig];\n");
29 printf("\telse\n");
30 printf("\t\treturn NULL;\n");
31 printf("}\n");