* tests/tests.h (signal2name): New prototype. * tests/signal2name.c: New file. * tests/Makefile.am (libtests_a_SOURCES): Add it. --- tests/Makefile.am | 1 + tests/signal2name.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/tests.h | 3 ++ 3 files changed, 129 insertions(+) create mode 100644 tests/signal2name.c
diff --git a/tests/Makefile.am b/tests/Makefile.am index 9eba306..ac527ec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -51,6 +51,7 @@ libtests_a_SOURCES = \ print_quoted_string.c \ printflags.c \ printxval.c \ + signal2name.c \ tail_alloc.c \ tests.h \ tprintf.c \ diff --git a/tests/signal2name.c b/tests/signal2name.c new file mode 100644 index 0000000..906e821 --- /dev/null +++ b/tests/signal2name.c @@ -0,0 +1,125 @@ +#include "tests.h" +#include <signal.h> + +#define CASE(x) case x: return #x + +const char * +signal2name(int sig) +{ + switch (sig) { +#ifdef SIGALRM + CASE(SIGALRM); +#endif +#ifdef SIGBUS + CASE(SIGBUS); +#endif +#ifdef SIGCHLD + CASE(SIGCHLD); +#endif +#ifdef SIGCONT + CASE(SIGCONT); +#endif +#ifdef SIGFPE + CASE(SIGFPE); +#endif +#ifdef SIGHUP + CASE(SIGHUP); +#endif +#ifdef SIGILL + CASE(SIGILL); +#endif +#ifdef SIGINT + CASE(SIGINT); +#endif +#ifdef SIGIO + CASE(SIGIO); +#endif +#ifdef SIGPIPE + CASE(SIGPIPE); +#endif +#ifdef SIGPROF + CASE(SIGPROF); +#endif +#ifdef SIGQUIT + CASE(SIGQUIT); +#endif +#ifdef SIGSEGV + CASE(SIGSEGV); +#endif +#ifdef SIGSYS + CASE(SIGSYS); +#endif +#ifdef SIGTERM + CASE(SIGTERM); +#endif +#ifdef SIGTRAP + CASE(SIGTRAP); +#endif +#ifdef SIGTSTP + CASE(SIGTSTP); +#endif +#ifdef SIGTTIN + CASE(SIGTTIN); +#endif +#ifdef SIGTTOU + CASE(SIGTTOU); +#endif +#ifdef SIGURG + CASE(SIGURG); +#endif +#ifdef SIGUSR1 + CASE(SIGUSR1); +#endif +#ifdef SIGUSR2 + CASE(SIGUSR2); +#endif +#ifdef SIGVTALRM + CASE(SIGVTALRM); +#endif +#ifdef SIGWINCH + CASE(SIGWINCH); +#endif +#ifdef SIGXCPU + CASE(SIGXCPU); +#endif +#ifdef SIGXFSZ + CASE(SIGXFSZ); +#endif +#if !defined MIPS +# ifdef SIGABRT + CASE(SIGABRT); +# endif +#endif +#if defined ALPHA || defined MIPS || defined SPARC +# ifdef SIGEMT + CASE(SIGEMT); +# endif +#endif +#ifdef ALPHA +# ifdef SIGINFO + CASE(SIGINFO); +# endif +#endif +#ifdef MIPS +# ifdef SIGIOT + CASE(SIGIOT); +# endif +#endif +#ifdef SPARC +# ifdef SIGLOST + CASE(SIGLOST); +# endif +#endif +#if !defined ALPHA && !defined SPARC +# ifdef SIGPWR + CASE(SIGPWR); +# endif +#endif +#if !defined ALPHA && !defined SPARC && !defined MIPS +# ifdef SIGSTKFLT + CASE(SIGSTKFLT); +# endif +#endif + default: perror_msg_and_fail("unknown signal number %d", sig); + } +} diff --git a/tests/tests.h b/tests/tests.h index 0205ea0..c140830 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -93,6 +93,9 @@ void check_overflowgid(const int); /* Translate errno to its name. */ const char *errno2name(void); +/* Translate signal number to its name. */ +const char *signal2name(int); + struct xlat; /* Print flags in symbolic form according to xlat table. */ -- 1.8.3.1 ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel