diff options
Diffstat (limited to 'sys/linux/src/errormsg.c')
-rw-r--r-- | sys/linux/src/errormsg.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/linux/src/errormsg.c b/sys/linux/src/errormsg.c new file mode 100644 index 0000000..e1d4b73 --- /dev/null +++ b/sys/linux/src/errormsg.c @@ -0,0 +1,26 @@ +#include "internal.h" + +static const struct ErrorMessage { +#define E(n, s) char str##n[sizeof(s)]; +#include "errno.inc.h" +#undef E +} errormsg = { +#define E(n, s) s, +#include "errno.inc.h" +#undef E +}; + +static const ushort errmsgidx[] = { +#define E(n, s) [n] = offsetof(struct ErrorMessage, str##n), +#include "errno.inc.h" +#undef E +}; + +char * +sys·errormsg(int errno) +{ + if(errno >= arrlen(errmsgidx)) + errno=0; + + return (char*)(&errormsg + errmsgidx[errno]); +} |