aboutsummaryrefslogtreecommitdiff
path: root/sys/linux/src/errormsg.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-11-19 05:44:21 -0800
committerNicholas Noll <nbnoll@eml.cc>2021-11-19 05:44:21 -0800
commit59d87ccc99f431da06a0ffab0d3e702d9ef82f48 (patch)
treee13de4f7e86cc731add3b3d3bcf3b32ce22adefc /sys/linux/src/errormsg.c
parent835dea0eb6333a9ef452881ea073bfe59d14096a (diff)
chore: make dependence on static syscalls explicit
Diffstat (limited to 'sys/linux/src/errormsg.c')
-rw-r--r--sys/linux/src/errormsg.c26
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]);
+}