mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add strsignal(3).
This commit is contained in:
parent
ffab25b0f4
commit
f1bbbe5153
3 changed files with 76 additions and 1 deletions
|
@ -116,6 +116,7 @@ strndup.o \
|
|||
strnlen.o \
|
||||
strpbrk.o \
|
||||
strrchr.o \
|
||||
strsignal.o \
|
||||
strspn.o \
|
||||
strstr.o \
|
||||
strtok.o \
|
||||
|
|
|
@ -68,7 +68,6 @@ size_t strxfrm(char* restrict, const char* restrict, size_t);
|
|||
int strcoll_l(const char*, const char*, locale_t);
|
||||
char* strerror_l(int, locale_t);
|
||||
int strerror_r(int, char*, size_t);
|
||||
char* strsignal(int);
|
||||
size_t strxfrm_l(char* restrict, const char* restrict, size_t, locale_t);
|
||||
#endif
|
||||
|
||||
|
@ -78,11 +77,14 @@ char* strchrnul(const char* str, int c);
|
|||
|
||||
#if defined(_SORTIX_SOURCE)
|
||||
const char* sortix_strerror(int errnum);
|
||||
const char* sortix_strsignal(int signum);
|
||||
#endif
|
||||
#if defined(_SOURCE_SOURCE) && __SORTIX_STDLIB_REDIRECTS
|
||||
const char* strerror(int errnum) asm ("sortix_strerror");
|
||||
const char* strsignal(int signum) asm ("sortix_strsignal");
|
||||
#else
|
||||
char* strerror(int errnum);
|
||||
char* strsignal(int signum);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
|
72
libc/strsignal.cpp
Normal file
72
libc/strsignal.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
strsignal.cpp
|
||||
Convert signal number to a string.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#define __SORTIX_STDLIB_REDIRECTS 0
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" const char* sortix_strsignal(int signum)
|
||||
{
|
||||
switch ( signum )
|
||||
{
|
||||
case SIGHUP: return "SIGHUP";
|
||||
case SIGINT: return "SIGINT";
|
||||
case SIGQUIT: return "SIGQUIT";
|
||||
case SIGILL: return "SIGILL";
|
||||
case SIGTRAP: return "SIGTRAP";
|
||||
case SIGABRT: return "SIGABRT";
|
||||
case SIGEMT: return "SIGEMT";
|
||||
case SIGFPE: return "SIGFPE";
|
||||
case SIGKILL: return "SIGKILL";
|
||||
case SIGBUS: return "SIGBUS";
|
||||
case SIGSEGV: return "SYSSEGV";
|
||||
case SIGSYS: return "SIGSYS";
|
||||
case SIGPIPE: return "SIGPIPE";
|
||||
case SIGALRM: return "SIGALRM";
|
||||
case SIGTERM: return "SIGTERM";
|
||||
case SIGUSR1: return "SIGUSR1";
|
||||
case SIGUSR2: return "SIGUSR2";
|
||||
case SIGCHLD: return "SIGCHLD";
|
||||
case SIGPWR: return "SIGPWR";
|
||||
case SIGWINCH: return "SIGWINCH";
|
||||
case SIGURG: return "SIGURG";
|
||||
case SIGSTOP: return "SIGSTOP";
|
||||
case SIGTSTP: return "SIGTSTP";
|
||||
case SIGCONT: return "SIGCONT";
|
||||
case SIGTTIN: return "SIGTTIN";
|
||||
case SIGTTOU: return "SIGTTOU";
|
||||
case SIGVTALRM: return "SIGVTALRM";
|
||||
case SIGXCPU: return "SIGXCPU";
|
||||
case SIGXFSZ: return "SIGXFSZ";
|
||||
case SIGWAITING: return "SIGWAITING";
|
||||
case SIGLWP: return "SIGLWP";
|
||||
case SIGAIO: return "SIGAIO";
|
||||
default: return "Unknown signal value";
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" char* strsignal(int signum)
|
||||
{
|
||||
return (char*) sortix_strsignal(signum);
|
||||
}
|
Loading…
Reference in a new issue