1 # Script to produce bits/errno.h for NaCl.
3 # Copyright (C) 2015 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
20 BEGIN { maxerrno =
0 }
22 $
1 ==
"#define" && $
2 ~
/NACL_ABI_E
[A
-Z0
-9_
]+/ && $
3 ~
/[0-9]+/ {
24 sub(/NACL_ABI_
/, "", ename
);
26 if (errno > maxerrno
) maxerrno =
errno;
27 errnos
[errno] = ename
;
28 errnos_by_name
[ename
] =
errno;
29 if ($
4 ==
"/*" && !
(ename in errno_text
)) {
31 for (i =
6; i
<=
NF && $i
!= "*/"; ++i
)
33 errno_text
[ename
] = etext
;
38 $
1 ==
"@comment" && $
2 ==
"errno.h" { errnoh=
1; next }
39 errnoh ==
1 && $
1 ==
"@comment" {
42 for (i =
4; i
<=
NF; ++i
)
46 errnoh ==
2 && $
1 ==
"@deftypevr" && $
2 ==
"Macro" && $
3 ==
"int" {
48 errno_text
[ename
] = etext
;
52 function define_errno
(errno, ename
) {
53 etext = errno_text
[ename
];
54 if (length(ename
) < 8) ename = ename
"\t";
55 printf "#define\t%s\t%d\t/* %s */\n", ename
, errno, etext
;
60 /* This file generated by errnos.awk. */\n\
62 #if !defined __Emath_defined && (defined _ERRNO_H || defined __need_Emath)\n\
63 #undef __need_Emath\n\
64 #define __Emath_defined 1";
65 emath
["EDOM"] = emath
["EILSEQ"] = emath
["ERANGE"] =
1;
66 for (ename in emath
) {
67 errno = errnos_by_name
[ename
];
68 define_errno
(errno, ename
);
76 for (i =
1; i
<= maxerrno
; ++i
)
77 if (i in errnos
) define_errno
(i
, errnos
[i
]);
80 #define EWOULDBLOCK EAGAIN\n\
81 #define ENOTSUP EOPNOTSUPP\n\
83 extern __thread int errno __attribute__ ((__tls_model__ (\"initial-exec\")));\n\
84 #define errno errno\n\