semtimedop: add time64 syscall support, decouple 32-bit time_t
[musl] / src / errno / strerror.c
1 #include <errno.h>
2 #include <string.h>
3 #include "locale_impl.h"
4
5 #define E(a,b) ((unsigned char)a),
6 static const unsigned char errid[] = {
7 #include "__strerror.h"
8 };
9
10 #undef E
11 #define E(a,b) b "\0"
12 static const char errmsg[] =
13 #include "__strerror.h"
14 ;
15
16 char *__strerror_l(int e, locale_t loc)
17 {
18         const char *s;
19         int i;
20         /* mips has one error code outside of the 8-bit range due to a
21          * historical typo, so we just remap it. */
22         if (EDQUOT==1133) {
23                 if (e==109) e=-1;
24                 else if (e==EDQUOT) e=109;
25         }
26         for (i=0; errid[i] && errid[i] != e; i++);
27         for (s=errmsg; i; s++, i--) for (; *s; s++);
28         return (char *)LCTRANS(s, LC_MESSAGES, loc);
29 }
30
31 char *strerror(int e)
32 {
33         return __strerror_l(e, CURRENT_LOCALE);
34 }
35
36 weak_alias(__strerror_l, strerror_l);