strsignal: signal name conversion
authorAlan Cox <alan@linux.intel.com>
Thu, 14 May 2015 22:51:04 +0000 (23:51 +0100)
committerAlan Cox <alan@linux.intel.com>
Thu, 14 May 2015 22:51:04 +0000 (23:51 +0100)
Library/include/string.h
Library/libs/Makefile
Library/libs/Makefile.6502
Library/libs/Makefile.6809
Library/libs/strsignal.c [new file with mode: 0644]

index 822e523..bf7d269 100644 (file)
@@ -59,6 +59,8 @@ extern size_t strnlen __P((const char *, size_t));
 extern size_t strxfrm __P((char *, const char *, size_t));
 extern int strcoll __P((const char *s1, const char *s2));
 
+extern const char *strsignal __P((int s));
+
 #ifdef z80
 #pagma inline(memcpy)
 #pagma inline(memset)
index 8fb1a70..92a469f 100644 (file)
@@ -4,7 +4,7 @@ AR = sdar
 LINKER = sdldz80
 # This gets set for 'awkward' devices like ZX128
 #PLATFORM = -zx128
-#PLATFORM =
+PLATFORM =
 export PLATFORM
 #CC_OPT = -mz80 -c --opt-code-size --std-c99 --max-allocs-per-node 2000000 -I../include
 CC_OPT = -mz80 --std-c99 -c --opt-code-size --max-allocs-per-node 20000 -I../include
@@ -36,7 +36,7 @@ SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c
 SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c 
 SRC_C += stat.c stdio0.c stime.c
 SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
-SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c
+SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c strsignal.c
 SRC_C += strtod.c strtol.c system.c time.c tmpfile.c tmpnam.c ttyname.c
 SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c
 SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c
index b75bbc7..c9cba5f 100644 (file)
@@ -50,7 +50,7 @@ SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c
 SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c
 SRC_C += stat.c stdio0.c stime.c
 SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
-SRC_C += strnicmp.c strnlen.c strsep.c
+SRC_C += strnicmp.c strnlen.c strsep.c strsignal.c
 SRC_C += system.c time.c tmpfile.c tmpnam.c ttyname.c
 SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c
 SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c
@@ -87,7 +87,7 @@ fuzix6502/Makefile: ../tools/syscall_6502.c ../../Kernel/include/syscall_name.h
 syslib.lib: fuzix6502/Makefile $(OBJ_C)
        (cd fuzix6502; make)
        $(AR) a syslib.lib $(OBJ_C)
-       ln -sf syslib.lib c.lib
+       ln -sf syslib.lib c6502.lib
 
 $(OBJ_ASM):%.o: %.s
        $(ASM) $(ASM_OPT) $@ $(@:.o=.s)
index efbb012..b7cc75c 100644 (file)
@@ -31,7 +31,7 @@ SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c
 SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c
 SRC_C += stat.c stdio0.c stime.c
 SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
-SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c
+SRC_C += strnlen.c strnicmp.c strsep.c strsignal.c strxfrm.c strcoll.c
 SRC_C += strtod.c strtol.c system.c time.c tmpfile.c tmpnam.c ttyname.c
 SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c
 SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c
diff --git a/Library/libs/strsignal.c b/Library/libs/strsignal.c
new file mode 100644 (file)
index 0000000..211fc81
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *     Implement strsignal and the C sys_siglist
+ */
+
+#include <string.h>
+#include <unistd.h>
+
+const char *sys_siglist[NSIGS] = {
+  "Unknown signal",
+  "Hangup",
+  "Interrupt",
+  "Quit",
+  "Illegal instruction",
+  "BPT trace/trap",
+  "ABORT instruction",
+  "I/O trap",
+  "Bus error",
+  "Floating point exception",
+  "Killed",
+  "User signal 1",
+  "User signal 2",
+  "Broken pipe",
+  "Alarm clock",
+  "Terminated",
+  "Stack fault",
+  "Child death or stop",
+  "Continue",
+  "Stopped",
+  "Stopped (signal)",
+  "Stopped (tty input)",
+  "Stopped (tty output)",
+  "Urgent IO condition",
+  "CPU limit",
+  "File limit",
+  "Alarm (virtual)",
+  "Alarm (profile)",
+  "Window changed",
+  "I/O ready",
+  "Power",
+  "Bad system call"
+};
+
+const char *strsignal(int s)
+{
+  if (s < 1 || s >= NSIGS)
+    s = 0;
+  return sys_siglist[s];
+}