Luna/libc/src/string.cpp

47 lines
1.4 KiB
C++

#include <bits/signal.h>
#include <luna/SystemError.h>
#include <string.h>
extern "C"
{
// All other string functions are defined in luna/CString.cpp, so the same definitions can be used by both kernel
// and userspace.
extern "C++" const char* error_string(int);
char* strerror(int errnum)
{
return const_cast<char*>(error_string(errnum));
}
static const char* __internal_strsignal(int signo)
{
switch (signo)
{
case SIGHUP: return "Hangup";
case SIGINT: return "Terminal interrupt";
case SIGQUIT: return "Terminal quit";
case SIGILL: return "Invalid opcode";
case SIGTRAP: return "Breakpoint trap";
case SIGABRT: return "Aborted";
case SIGCHLD: return "Child stopped or exited";
case SIGFPE: return "Floating point exception";
case SIGKILL: return "Killed";
case SIGSTOP: return "Stopped";
case SIGSEGV: return "Segmentation fault";
case SIGCONT: return "Continued";
case SIGPIPE: return "Broken pipe";
case SIGALRM: return "Alarm signal";
case SIGTERM: return "Terminated";
case SIGTTIN: return "Background process stopped (terminal input)";
case SIGTTOU: return "Background process stopped (terminal output)";
default: return "Unknown signal";
}
}
char* strsignal(int signo)
{
return const_cast<char*>(__internal_strsignal(signo));
}
}