Luna/libc/src/string.cpp

53 lines
1.6 KiB
C++
Raw Normal View History

#include <bits/signal.h>
#include <luna/SystemError.h>
#include <string.h>
extern "C"
{
2023-03-12 09:45:21 +00:00
// 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);
2023-08-08 12:40:14 +00:00
int strcoll(const char* a, const char* b)
{
// In the POSIX or C locales strcoll() is equivalent to strcmp().
return strcmp(a, b);
}
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));
}
}