521fa314e2
Change-Id: Ib970c8647409196902ed53d6e9631a1673a4ab2e
32 lines
970 B
Awk
32 lines
970 B
Awk
# This one is a bit trickier than error.awk, because sys/signal.h is not as
|
|
# easy to parse. We currently assume that all (userland) signals are listed
|
|
# before the first reference to "_KERNEL", and anything else that looks like a
|
|
# signal definition (but isn't) is after that first reference.
|
|
|
|
BEGIN {
|
|
printf("/* This file is automatically generated by signal.awk */\n\n");
|
|
printf("#include \"inc.h\"\n\n");
|
|
printf("static const char *const signals[] = {\n");
|
|
}
|
|
/^#define/ {
|
|
name = $2;
|
|
if (!match(name, "SIG[^_]"))
|
|
next;
|
|
number = $3;
|
|
if (number < 0 || number == "SIGABRT")
|
|
next;
|
|
printf("\t[%s] = \"%s\",\n", name, name);
|
|
}
|
|
/_KERNEL/ {
|
|
exit;
|
|
}
|
|
END {
|
|
printf("};\n\n");
|
|
printf("const char *\nget_signal_name(int sig)\n{\n\n");
|
|
printf("\tif (sig >= 0 && sig < sizeof(signals) / sizeof(signals[0]) &&\n");
|
|
printf("\t signals[sig] != NULL)\n");
|
|
printf("\t\treturn signals[sig];\n");
|
|
printf("\telse\n");
|
|
printf("\t\treturn NULL;\n");
|
|
printf("}\n");
|
|
}
|