summaryrefslogtreecommitdiff
path: root/src/libc/string/strerror.c
blob: c8382994e7710901eb94838a6f4d5698af5bfe2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string.h>

static const char *errstr[] = {
#	define E(n, str) [n] = str,
#	include <__errno.h>
#	undef E
};

char *strerror(int n) {
	if (0 <= n && n * sizeof(*errstr) < sizeof(errstr) && errstr[n])
		return (char*)errstr[n];
	return "unknown error";
}