Implement strerror() #5

Merged
apio merged 2 commits from strerror into main 2022-10-08 10:32:12 +00:00
2 changed files with 19 additions and 0 deletions
Showing only changes of commit 8f0b6d80b2 - Show all commits

View File

@ -23,6 +23,8 @@ extern "C"
deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char*, const char*); deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char*, const char*);
char* strncat(char*, const char*, size_t); char* strncat(char*, const char*, size_t);
char* strerror(int);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,3 +1,4 @@
#include <errno.h>
#include <luna.h> #include <luna.h>
#include <string.h> #include <string.h>
@ -108,4 +109,20 @@ extern "C"
// we return "m_start" + the amount of bytes that were transfered // we return "m_start" + the amount of bytes that were transfered
return (void*)(((size_t)start) + i); return (void*)(((size_t)start) + i);
} }
#pragma GCC push_options
#pragma GCC diagnostic ignored "-Wwrite-strings"
char* strerror(int errnum)
{
switch (errnum)
{
case EPERM: return "Operation not permitted";
case EINVAL: return "Invalid argument";
case ENOMEM: return "Out of memory";
default: return 0;
}
}
#pragma GCC pop_options
} }