Remove "[Add new features here]" for 2.27
[glibc.git] / sysdeps / gnu / errlist.awk
blobd5a05551149a217119b985a8c22a6816522439da
1 # Copyright (C) 1991-2017 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <http://www.gnu.org/licenses/>.
18 # errno.texi contains lines like:
19 # @deftypevr Macro int ENOSYS
20 # @errno{ENOSYS, 78, Function not implemented}
21 # Descriptive paragraph...
22 # @end deftypevr
24 BEGIN {
26 # Here we list the E* names that might be duplicate names for the
27 # same integer value on some systems. This causes the code below
28 # to generate ``#if defined (ALIAS) && ALIAS != ORIGINAL'' in the code,
29 # so the output does not presume that these are in fact aliases.
30 # We list here all the known potential cases on any system,
31 # so that the C source we produce will do the right thing based
32 # on the actual #define'd values it's compiled with.
33 alias["EWOULDBLOCK"]= "EAGAIN";
34 alias["EDEADLOCK"] = "EDEADLK";
35 alias["ENOTSUP"] = "EOPNOTSUPP";
37 print "/* This file is generated from errno.texi by errlist.awk. */"
38 print "";
39 print "#include <errno.h>";
40 print "#include <libintl.h>";
41 print "";
42 print "#ifndef ERR_REMAP";
43 print "# define ERR_REMAP(n) n";
44 print "#endif";
45 print "";
47 print "#if !defined EMIT_ERR_MAX && !defined ERRLIST_NO_COMPAT";
48 print "# include <errlist-compat.h>";
49 print "#endif";
50 print "#ifdef ERR_MAX";
51 print "# define ERRLIST_SIZE ERR_MAX + 1";
52 print "#else"
53 print "# define ERR_MAX 0";
54 print "# define ERRLIST_SIZE";
55 print "#endif";
57 print "const char *const _sys_errlist_internal[ERRLIST_SIZE] =";
58 print " {";
59 print " [0] = N_(\"Success\"),"
62 /^@errno\{/ \
64 etext = $3;
65 for (i = 4; i <= NF; ++i)
66 etext = etext " " $i;
67 etext = substr(etext, 1, length(etext)-1)
68 e = substr($1, 8, length($1)-8)
69 errno = substr($2, 1, length($2)-1) + 0
70 if (alias[e])
71 printf "#if defined (%s) && %s != %s\n", e, e, alias[e];
72 else
73 printf "#ifdef %s\n", e;
74 errnoh = 4;
75 desc="";
76 next;
78 errnoh == 4 && $1 == "@end" && $2 == "deftypevr" \
80 printf "/*%s */\n", desc;
81 printf " [ERR_REMAP (%s)] = N_(\"%s\"),\n", e, etext;
82 printf "# if %s > ERR_MAX\n", e;
83 print "# undef ERR_MAX";
84 printf "# define ERR_MAX %s\n", e;
85 print "# endif";
86 print "#endif";
87 errnoh = 0;
88 next;
90 errnoh == 4 \
92 # This magic tag in C comments gets them copied into libc.pot.
93 desc = desc "\nTRANS" ($0 != "" ? " " : "") $0; next
95 END {
96 print " };";
97 print "";
98 print "#define NERR \\";
99 print " (sizeof _sys_errlist_internal / sizeof _sys_errlist_internal [0])";
100 print "const int _sys_nerr_internal = NERR;"
101 print "";
102 print "#if IS_IN (libc) && !defined ERRLIST_NO_COMPAT";
103 print "# include <errlist-compat.c>";
104 print "#endif";
105 print "";
106 print "#ifdef EMIT_ERR_MAX";
107 print "void dummy (void)"
108 print "{ asm volatile (\" @@@ %0 @@@ \" : : \"i\" (ERR_REMAP (ERR_MAX))); }"
109 print "#endif";