• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <errno.h>
2 #include <stddef.h>
3 #include <string.h>
4 #include "locale_impl.h"
5 
6 static const struct errmsgstr_t {
7 #define E(n, s) char str##n[sizeof(s)];
8 #include "__strerror.h"
9 #undef E
10 } errmsgstr = {
11 #define E(n, s) s,
12 #include "__strerror.h"
13 #undef E
14 };
15 
16 static const unsigned short errmsgidx[] = {
17 #define E(n, s) [n] = offsetof(struct errmsgstr_t, str##n),
18 #include "__strerror.h"
19 #undef E
20 };
21 
__strerror_l(int e,locale_t loc)22 char *__strerror_l(int e, locale_t loc)
23 {
24 	const char *s;
25 
26 	if (e >= sizeof errmsgidx / sizeof *errmsgidx) e = 0;
27 	s = (char *)&errmsgstr + errmsgidx[e];
28 	return (char *)s;
29 }
30 
strerror(int e)31 char *strerror(int e)
32 {
33 	return __strerror_l(e, CURRENT_LOCALE);
34 }
35 
36 weak_alias(__strerror_l, strerror_l);
37