hurd: Define EXEC_PAGESIZE
[glibc.git] / sysdeps / mach / hurd / errnos.awk
blobbc69e06bf6b90c031cf7addcba2cd0410cdf1d2e
1 # Copyright (C) 1991-2018 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.texinfo contains lines like:
19 # @errno{ENOSYS, 123, Function not implemented}
21 BEGIN {
22 print "/* This file generated by errnos.awk from";
23 for (i = 1; i < ARGC; i++)
25 arg = ARGV[i];
26 sub(/.*(manual|include)\//, "", arg)
27 print " " arg;
29 print " Do not edit this file; edit errnos.awk and regenerate it. */";
30 print "";
31 print "#ifndef _BITS_ERRNO_H";
32 print "#define _BITS_ERRNO_H 1";
33 print "";
34 print "#if !defined _ERRNO_H";
35 print "# error \"Never include <bits/errno.h> directly; use <errno.h> instead.\"";
36 print "#endif";
38 maxerrno = 0;
39 maxerrlen = 0;
40 in_mach_errors = "";
41 seq = 0;
44 /^@errno\{/ \
46 e = substr($1, 8, length($1)-8)
47 if (length(e) > maxerrlen)
48 maxerrlen = length(e);
49 if (e == "EWOULDBLOCK")
51 econsts[seq] = e;
52 errnos[seq] = "EAGAIN";
53 seq++;
54 next;
57 errno = substr($2, 1, length($2)-1) + 0;
58 if (errno == 0)
59 next;
60 if (errno > 0x3ffff)
62 printf("%s:%d: errno value %d too large for the Hurd\n",
63 FILENAME, NR, errno) >> "/dev/stderr";
64 exit 1;
66 if (errno > maxerrno)
67 maxerrno = errno;
69 etext = "";
70 for (i = 3; i <= NF; ++i)
71 etext = etext " " $i;
72 etext = substr(etext, 2, length(etext)-2);
74 econsts[seq] = e;
75 errnos[seq] = sprintf("0x%08x", 0x40000000 + errno);
76 etexts[seq] = etext;
77 seq++;
78 next;
81 NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
83 in_mach_errors = FILENAME;
84 annot[seq++] = "\n/* Errors from <mach/message.h>. */";
86 NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
88 in_mach_errors = FILENAME;
89 annot[seq++] = "\n/* Errors from <mach/kern_return.h>. */";
90 next;
93 in_mach_errors != "" && $2 == "MACH_IPC_COMPAT" \
95 in_mach_errors = "";
98 # FIXME: mach/message.h and mach/kern_return.h do include error
99 # descriptions which we could slurp, but some of them are very long,
100 # we would need to word-wrap them.
101 in_mach_errors == FILENAME && NF == 3 && $1 == "#define" \
103 e = "E" $2;
104 if (length(e) > maxerrlen)
105 maxerrlen = length(e);
106 econsts[seq] = e;
107 errnos[seq] = $3;
108 etexts[seq] = "";
109 seq++;
112 $1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
114 in_mig_errors = 1;
115 annot[seq++] = "\n/* Errors from <mach/mig_errors.h>. */";
116 next;
118 in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
120 in_mig_errors = 0;
123 (in_mig_errors && $1 == "#define" && $3 <= -300) || \
124 (in_device_errors && $1 == "#define" && /D_/ && NF > 3) \
126 etext = "";
127 for (i = 5; i < NF; ++i)
128 etext = etext " " $i;
130 e = "E" $2;
131 if (length(e) > maxerrlen)
132 maxerrlen = length(e);
133 econsts[seq] = e;
134 errnos[seq] = $3;
135 etexts[seq] = substr(etext, 2, length(etext)-1);
136 seq++;
139 $1 == "#define" && $2 == "D_SUCCESS" \
141 in_device_errors = 1;
142 annot[seq++] = "\n/* Errors from <device/device_types.h>. */";
143 next;
145 in_device_errors && $1 == "#endif" \
147 in_device_errors = 0;
150 function print_errno_enum(maxseq)
152 print "";
153 print "#ifndef __ASSEMBLER__";
154 print "";
155 print "enum __error_t_codes";
156 print "{";
157 print " /* The value zero always means success and it is perfectly fine";
158 print " for code to use 0 explicitly (or implicitly, e.g. via Boolean";
159 print " coercion.) Having an enum entry for zero both makes the";
160 print " debugger print the name for error_t-typed zero values, and";
161 print " prevents the compiler from issuing warnings about 'case 0:'";
162 print " in a switch on an error_t-typed value. */";
163 printf(" %-*s = 0,\n", maxerrlen, "ESUCCESS");
165 print "";
166 print " /* The Hurd uses Mach error system 0x10, subsystem 0. */";
167 for (i = 0; i < maxseq; i++)
169 if (i in annot)
170 print annot[i];
171 else if (i in etexts && etexts[i] != "")
172 printf(" %-*s = %s,\t/* %s */\n",
173 maxerrlen, econsts[i], errnos[i], etexts[i]);
174 else if (errnos[i] != "EAGAIN")
175 printf(" %-*s = %s,\n", maxerrlen, econsts[i], errnos[i]);
178 print "";
179 print " /* Because the C standard requires that errno have type 'int',"
180 print " this enumeration must be a signed type. */";
181 print " __FORCE_ERROR_T_CODES_SIGNED = -1";
182 print "};";
183 print "";
184 print "/* User-visible type of error codes. It is ok to use 'int' or";
185 print " 'kern_return_t' for these, but with 'error_t' the debugger prints";
186 print " symbolic values. */";
187 print "# if !defined __error_t_defined && defined __USE_GNU";
188 print "# define __error_t_defined 1";
189 print "typedef enum __error_t_codes error_t;"
190 print "# endif";
191 print "";
192 print "#endif /* not __ASSEMBLER__ */";
195 function print_errno_defines(maxseq)
197 print "";
198 print "/* The C standard requires that all of the E-constants be"
199 print " defined as macros. */"
200 print "";
201 for (i = 0; i < maxseq; i++)
203 if (i in annot)
204 print annot[i];
205 else
206 printf("#define %-*s %s\n", maxerrlen, econsts[i], errnos[i]);
208 print "";
209 printf("#define _HURD_ERRNOS %d\n", maxerrno+1);
212 END \
214 print_errno_enum(seq);
215 print_errno_defines(seq);
217 print "";
218 print "#endif /* bits/errno.h. */";