musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/string/strsignal.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011年02月12日 00:22:29 -0500
committerRich Felker <dalias@aerifal.cx>2011年02月12日 00:22:29 -0500
commit0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 (patch)
tree6eaef0d8a720fa3da580de87b647fff796fe80b3 /src/string/strsignal.c
downloadmusl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.gz
initial check-in, version 0.5.0v0.5.0
Diffstat (limited to 'src/string/strsignal.c')
-rw-r--r--src/string/strsignal.c 98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/string/strsignal.c b/src/string/strsignal.c
new file mode 100644
index 00000000..72fba8d1
--- /dev/null
+++ b/src/string/strsignal.c
@@ -0,0 +1,98 @@
+#include <signal.h>
+
+#if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) \
+ && (SIGTRAP == 5) && (SIGABRT == 6) && (SIGBUS == 7) && (SIGFPE == 8) \
+ && (SIGKILL == 9) && (SIGUSR1 == 10) && (SIGSEGV == 11) && (SIGUSR2 == 12) \
+ && (SIGPIPE == 13) && (SIGALRM == 14) && (SIGTERM == 15) && (SIGSTKFLT == 16) \
+ && (SIGCHLD == 17) && (SIGCONT == 18) && (SIGSTOP == 19) && (SIGTSTP == 20) \
+ && (SIGTTIN == 21) && (SIGTTOU == 22) && (SIGURG == 23) && (SIGXCPU == 24) \
+ && (SIGXFSZ == 25) && (SIGVTALRM == 26) && (SIGPROF == 27) && (SIGWINCH == 28) \
+ && (SIGPOLL == 29) && (SIGPWR == 30) && (SIGSYS == 31)
+
+#define sigmap(x) x
+
+#else
+
+static const char map[] = {
+ [SIGHUP] = 1,
+ [SIGINT] = 2,
+ [SIGQUIT] = 3,
+ [SIGILL] = 4,
+ [SIGTRAP] = 5,
+ [SIGABRT] = 6,
+ [SIGBUS] = 7,
+ [SIGFPE] = 8,
+ [SIGKILL] = 9,
+ [SIGUSR1] = 10,
+ [SIGSEGV] = 11,
+ [SIGUSR2] = 12,
+ [SIGPIPE] = 13,
+ [SIGALRM] = 14,
+ [SIGTERM] = 15,
+ [SIGSTKFLT] = 16,
+ [SIGCHLD] = 17,
+ [SIGCONT] = 18,
+ [SIGSTOP] = 19,
+ [SIGTSTP] = 20,
+ [SIGTTIN] = 21,
+ [SIGTTOU] = 22,
+ [SIGURG] = 23,
+ [SIGXCPU] = 24,
+ [SIGXFSZ] = 25,
+ [SIGVTALRM] = 26,
+ [SIGPROF] = 27,
+ [SIGWINCH] = 28,
+ [SIGPOLL] = 29,
+ [SIGPWR] = 30,
+ [SIGSYS] = 31
+};
+
+#define sigmap(x) ((unsigned)(x) > sizeof map ? 0 : map[(unsigned)(x)])
+
+#endif
+
+static const char strings[] =
+ "Unknown signal0円"
+ "Hangup0円"
+ "Interrupt0円"
+ "Quit0円"
+ "Illegal instruction0円"
+ "Trace/breakpoint trap0円"
+ "Aborted0円"
+ "Bus error0円"
+ "Floating point exception0円"
+ "Killed0円"
+ "User defined signal 10円"
+ "Segmentation fault0円"
+ "User defined signal 20円"
+ "Broken pipe0円"
+ "Alarm clock0円"
+ "Terminated0円"
+ "Stack fault0円"
+ "Child exited0円"
+ "Continued0円"
+ "Stopped (signal)0円"
+ "Stopped0円"
+ "Stopped (tty input)0円"
+ "Stopped (tty output)0円"
+ "Urgent I/O condition0円"
+ "CPU time limit exceeded0円"
+ "File size limit exceeded0円"
+ "Virtual timer expired0円"
+ "Profiling timer expired0円"
+ "Window changed0円"
+ "I/O possible0円"
+ "Power failure0円"
+ "Bad system call";
+
+char *strsignal(int signum)
+{
+ char *s = (char *)strings;
+
+ signum = sigmap(signum);
+ if ((unsigned)signum - 1 > 31) signum = 0;
+
+ for (; signum--; s++) for (; *s; s++);
+
+ return s;
+}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月07日 10:59:58 +0000

AltStyle によって変換されたページ (->オリジナル) /