master
  1#include <signal.h>
  2#include <string.h>
  3#include "locale_impl.h"
  4
  5#if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) \
  6 && (SIGTRAP == 5) && (SIGABRT == 6) && (SIGBUS == 7) && (SIGFPE == 8) \
  7 && (SIGKILL == 9) && (SIGUSR1 == 10) && (SIGSEGV == 11) && (SIGUSR2 == 12) \
  8 && (SIGPIPE == 13) && (SIGALRM == 14) && (SIGTERM == 15) && (SIGSTKFLT == 16) \
  9 && (SIGCHLD == 17) && (SIGCONT == 18) && (SIGSTOP == 19) && (SIGTSTP == 20) \
 10 && (SIGTTIN == 21) && (SIGTTOU == 22) && (SIGURG == 23) && (SIGXCPU == 24) \
 11 && (SIGXFSZ == 25) && (SIGVTALRM == 26) && (SIGPROF == 27) && (SIGWINCH == 28) \
 12 && (SIGPOLL == 29) && (SIGPWR == 30) && (SIGSYS == 31)
 13
 14#define sigmap(x) x
 15
 16#else
 17
 18static const char map[] = {
 19	[SIGHUP]    = 1,
 20	[SIGINT]    = 2,
 21	[SIGQUIT]   = 3,
 22	[SIGILL]    = 4,
 23	[SIGTRAP]   = 5,
 24	[SIGABRT]   = 6,
 25	[SIGBUS]    = 7,
 26	[SIGFPE]    = 8,
 27	[SIGKILL]   = 9,
 28	[SIGUSR1]   = 10,
 29	[SIGSEGV]   = 11,
 30	[SIGUSR2]   = 12,
 31	[SIGPIPE]   = 13,
 32	[SIGALRM]   = 14,
 33	[SIGTERM]   = 15,
 34#if defined(SIGSTKFLT)
 35	[SIGSTKFLT] = 16,
 36#elif defined(SIGEMT)
 37	[SIGEMT]    = 16,
 38#endif
 39	[SIGCHLD]   = 17,
 40	[SIGCONT]   = 18,
 41	[SIGSTOP]   = 19,
 42	[SIGTSTP]   = 20,
 43	[SIGTTIN]   = 21,
 44	[SIGTTOU]   = 22,
 45	[SIGURG]    = 23,
 46	[SIGXCPU]   = 24,
 47	[SIGXFSZ]   = 25,
 48	[SIGVTALRM] = 26,
 49	[SIGPROF]   = 27,
 50	[SIGWINCH]  = 28,
 51	[SIGPOLL]   = 29,
 52	[SIGPWR]    = 30,
 53	[SIGSYS]    = 31
 54};
 55
 56#define sigmap(x) ((x) >= sizeof map ? (x) : map[(x)])
 57
 58#endif
 59
 60static const char strings[] =
 61	"Unknown signal\0"
 62	"Hangup\0"
 63	"Interrupt\0"
 64	"Quit\0"
 65	"Illegal instruction\0"
 66	"Trace/breakpoint trap\0"
 67	"Aborted\0"
 68	"Bus error\0"
 69	"Arithmetic exception\0"
 70	"Killed\0"
 71	"User defined signal 1\0"
 72	"Segmentation fault\0"
 73	"User defined signal 2\0"
 74	"Broken pipe\0"
 75	"Alarm clock\0"
 76	"Terminated\0"
 77#if defined(SIGSTKFLT)
 78	"Stack fault\0"
 79#elif defined(SIGEMT)
 80	"Emulator trap\0"
 81#else
 82	"Unknown signal\0"
 83#endif
 84	"Child process status\0"
 85	"Continued\0"
 86	"Stopped (signal)\0"
 87	"Stopped\0"
 88	"Stopped (tty input)\0"
 89	"Stopped (tty output)\0"
 90	"Urgent I/O condition\0"
 91	"CPU time limit exceeded\0"
 92	"File size limit exceeded\0"
 93	"Virtual timer expired\0"
 94	"Profiling timer expired\0"
 95	"Window changed\0"
 96	"I/O possible\0"
 97	"Power failure\0"
 98	"Bad system call\0"
 99	"RT32"
100	"\0RT33\0RT34\0RT35\0RT36\0RT37\0RT38\0RT39\0RT40"
101	"\0RT41\0RT42\0RT43\0RT44\0RT45\0RT46\0RT47\0RT48"
102	"\0RT49\0RT50\0RT51\0RT52\0RT53\0RT54\0RT55\0RT56"
103	"\0RT57\0RT58\0RT59\0RT60\0RT61\0RT62\0RT63\0RT64"
104#if _NSIG > 65
105	"\0RT65\0RT66\0RT67\0RT68\0RT69\0RT70\0RT71\0RT72"
106	"\0RT73\0RT74\0RT75\0RT76\0RT77\0RT78\0RT79\0RT80"
107	"\0RT81\0RT82\0RT83\0RT84\0RT85\0RT86\0RT87\0RT88"
108	"\0RT89\0RT90\0RT91\0RT92\0RT93\0RT94\0RT95\0RT96"
109	"\0RT97\0RT98\0RT99\0RT100\0RT101\0RT102\0RT103\0RT104"
110	"\0RT105\0RT106\0RT107\0RT108\0RT109\0RT110\0RT111\0RT112"
111	"\0RT113\0RT114\0RT115\0RT116\0RT117\0RT118\0RT119\0RT120"
112	"\0RT121\0RT122\0RT123\0RT124\0RT125\0RT126\0RT127\0RT128"
113#endif
114	"";
115
116char *strsignal(int signum)
117{
118	const char *s = strings;
119
120	signum = sigmap(signum);
121	if (signum - 1U >= _NSIG-1) signum = 0;
122
123	for (; signum--; s++) for (; *s; s++);
124
125	return (char *)LCTRANS_CUR(s);
126}