]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/mach/hurd/errnos.awk
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / mach / hurd / errnos.awk
CommitLineData
b168057a 1# Copyright (C) 1991-2015 Free Software Foundation, Inc.
28f540f4
RM
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
28f540f4
RM
8
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
41bdb6e2 12# Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15# License along with the GNU C Library; if not, see
16# <http://www.gnu.org/licenses/>.
28f540f4
RM
17
18# errno.texinfo contains lines like:
19# @comment errno.h
20# @comment POSIX.1: Function not implemented
21# @deftypevr Macro int ENOSYS
0923c7a5 22# @comment errno 123
28f540f4
RM
23
24BEGIN {
8f0c527e 25 print "/* This file generated by errnos.awk. */";
28f540f4
RM
26 print "";
27 print "/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */";
28 print "#ifndef _HURD_ERRNO";
29 print "#define _HURD_ERRNO(n)\t((0x10 << 26) | ((n) & 0x3fff))";
30 print "#endif";
31 print "";
32 print "#ifdef _ERRNO_H\n";
33 print "enum __error_t_codes\n{";
88335980
TS
34 print "\t/* The value zero always means success and it is perfectly fine for";
35 print "\t code to use 0 explicitly (or implicitly, e.g. via Boolean coercion).";
36 print "\t Having an enum entry for zero both makes the debugger print the name";
37 print "\t for error_t-typed zero values, and prevents the compiler from";
38 print "\t issuing warnings about 'case 0:' in a switch on an error_t-typed";
39 print "\t value. */";
40 print "\tESUCCESS = 0,"
41 print "";
28f540f4
RM
42 errnoh = 0;
43 maxerrno = 0;
aa1075ea 44 in_mach_errors = "";
28f540f4
RM
45 in_math = 0;
46 edom = erange = "";
47 print "#undef EDOM\n#undef ERANGE";
b2c4f152 48 lno = 0;
28f540f4
RM
49 }
50
51$1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
52$1 == "@comment" && errnoh == 1 \
53 {
54 ++errnoh;
55 etext = "";
56 for (i = 3; i <= NF; ++i)
57 etext = etext " " $i;
58 next;
59 }
60
61errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
62 { ++errnoh; e = $4; next; }
63
64errnoh == 3 && $1 == "@comment" && $2 == "errno" {
28f540f4
RM
65 if (e == "EWOULDBLOCK")
66 {
b2c4f152 67 lines[lno++]="#define EWOULDBLOCK EAGAIN /* Operation would block */";
28f540f4
RM
68 next;
69 }
49b98627
RM
70 errno = $3 + 0;
71 if (errno == 0)
72 next;
73 if (errno > maxerrno) maxerrno = errno;
28f540f4
RM
74 x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
75 "_HURD_ERRNO (" errno ")"),
76 etext);
77 if (e == "EDOM")
78 edom = x;
79 else if (e == "ERANGE")
80 erange = x;
b2c4f152
MK
81 comma[lno] = 1;
82 lines[lno++] = sprintf("\t%-16s= _HURD_ERRNO (%d)", e, errno);
83 lines[lno++] = x;
28f540f4
RM
84 next;
85 }
86{ errnoh=0 }
87
88NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
89 {
aa1075ea 90 in_mach_errors = FILENAME;
b2c4f152 91 lines[lno++] = "\n\t/* Errors from <mach/message.h>. */";
28f540f4
RM
92 }
93NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
94 {
aa1075ea 95 in_mach_errors = FILENAME;
b2c4f152 96 lines[lno++] = "\n\t/* Errors from <mach/kern_return.h>. */";
28f540f4
RM
97 next;
98 }
99
aa1075ea 100in_mach_errors != "" && $2 == "MACH_IPC_COMPAT" \
28f540f4 101 {
aa1075ea 102 in_mach_errors = "";
28f540f4
RM
103 }
104
aa1075ea 105in_mach_errors == FILENAME && NF == 3 && $1 == "#define" \
28f540f4 106 {
b2c4f152
MK
107 comma[lno] = 1;
108 lines[lno++] = sprintf("\t%-32s= %s", "E" $2, $3);
28f540f4
RM
109 }
110
111$1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
112 {
113 in_mig_errors = 1;
b2c4f152 114 lines[lno++] = "\n\t/* Errors from <mach/mig_errors.h>. */";
28f540f4
RM
115 next;
116 }
117in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
118 {
119 in_mig_errors = 0;
120 }
121
122(in_mig_errors && $1 == "#define" && $3 <= -300) || \
d2fcc3ae 123(in_device_errors && $1 == "#define" && /D_/ && NF > 3) \
28f540f4 124 {
b2c4f152 125 comment = "";
28f540f4 126 for (i = 4; i <= NF; ++i)
b2c4f152
MK
127 comment = comment " " $i;
128 comma[lno] = 1;
129 lines[lno++] = sprintf("%-32s", sprintf ("\t%-24s= %s", "E" $2, $3)) comment;
28f540f4
RM
130 }
131
132$1 == "#define" && $2 == "D_SUCCESS" \
133 {
134 in_device_errors = 1;
b2c4f152 135 lines[lno++] = "\n\t/* Errors from <device/device_types.h>. */";
28f540f4
RM
136 next;
137 }
138in_device_errors && $1 == "#endif" \
139 {
140 in_device_errors = 0;
141 }
142
143
144END \
145 {
b2c4f152
MK
146 for (i = 0; i < lno - 1; ++i)
147 printf "%s%s\n", lines[i], (comma[i] ? "," : "");
148 print lines[i];
28f540f4
RM
149 print "";
150 print "};";
151 print "";
152 printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1;
153 print "";
154 print "\
155/* User-visible type of error codes. It is ok to use `int' or\n\
156 `kern_return_t' for these, but with `error_t' the debugger prints\n\
157 symbolic values. */";
158 print "#ifdef __USE_GNU";
159 print "typedef enum __error_t_codes error_t;"
392d7920 160 print "#define __error_t_defined\t1"
28f540f4
RM
161 print "#endif";
162 print "";
7d55d698
RM
163 print "\
164/* Return the current thread's location for `errno'.\n\
165 The syntax of this function allows redeclarations like `int errno'. */\n\
166extern int *__errno_location (void) __THROW __attribute__ ((__const__));\n\
167\n\
168#define errno (*__errno_location ())\n\
7d55d698 169";
28f540f4
RM
170 print "#endif /* <errno.h> included. */";
171 print "";
172 print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
173 print edom; print erange;
174 print "#endif /* <errno.h> not included and need math error codes. */";
175 }