]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/mach/hurd/errnos.awk
Update copyright notices with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / mach / hurd / errnos.awk
1 # Copyright (C) 1991-2013 Free Software Foundation, Inc.
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
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.
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
12 # Lesser General Public License for more details.
13
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/>.
17
18 # errno.texinfo contains lines like:
19 # @comment errno.h
20 # @comment POSIX.1: Function not implemented
21 # @deftypevr Macro int ENOSYS
22 # @comment errno 123
23
24 BEGIN {
25 print "/* This file generated by errnos.awk. */";
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{";
34 errnoh = 0;
35 maxerrno = 0;
36 in_mach_errors = "";
37 in_math = 0;
38 edom = erange = "";
39 print "#undef EDOM\n#undef ERANGE";
40 lno = 0;
41 }
42
43 $1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
44 $1 == "@comment" && errnoh == 1 \
45 {
46 ++errnoh;
47 etext = "";
48 for (i = 3; i <= NF; ++i)
49 etext = etext " " $i;
50 next;
51 }
52
53 errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
54 { ++errnoh; e = $4; next; }
55
56 errnoh == 3 && $1 == "@comment" && $2 == "errno" {
57 if (e == "EWOULDBLOCK")
58 {
59 lines[lno++]="#define EWOULDBLOCK EAGAIN /* Operation would block */";
60 next;
61 }
62 errno = $3 + 0;
63 if (errno == 0)
64 next;
65 if (errno > maxerrno) maxerrno = errno;
66 x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
67 "_HURD_ERRNO (" errno ")"),
68 etext);
69 if (e == "EDOM")
70 edom = x;
71 else if (e == "ERANGE")
72 erange = x;
73 comma[lno] = 1;
74 lines[lno++] = sprintf("\t%-16s= _HURD_ERRNO (%d)", e, errno);
75 lines[lno++] = x;
76 next;
77 }
78 { errnoh=0 }
79
80 NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
81 {
82 in_mach_errors = FILENAME;
83 lines[lno++] = "\n\t/* Errors from <mach/message.h>. */";
84 }
85 NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
86 {
87 in_mach_errors = FILENAME;
88 lines[lno++] = "\n\t/* Errors from <mach/kern_return.h>. */";
89 next;
90 }
91
92 in_mach_errors != "" && $2 == "MACH_IPC_COMPAT" \
93 {
94 in_mach_errors = "";
95 }
96
97 in_mach_errors == FILENAME && NF == 3 && $1 == "#define" \
98 {
99 comma[lno] = 1;
100 lines[lno++] = sprintf("\t%-32s= %s", "E" $2, $3);
101 }
102
103 $1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
104 {
105 in_mig_errors = 1;
106 lines[lno++] = "\n\t/* Errors from <mach/mig_errors.h>. */";
107 next;
108 }
109 in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
110 {
111 in_mig_errors = 0;
112 }
113
114 (in_mig_errors && $1 == "#define" && $3 <= -300) || \
115 (in_device_errors && $1 == "#define" && /D_/ && NF > 3) \
116 {
117 comment = "";
118 for (i = 4; i <= NF; ++i)
119 comment = comment " " $i;
120 comma[lno] = 1;
121 lines[lno++] = sprintf("%-32s", sprintf ("\t%-24s= %s", "E" $2, $3)) comment;
122 }
123
124 $1 == "#define" && $2 == "D_SUCCESS" \
125 {
126 in_device_errors = 1;
127 lines[lno++] = "\n\t/* Errors from <device/device_types.h>. */";
128 next;
129 }
130 in_device_errors && $1 == "#endif" \
131 {
132 in_device_errors = 0;
133 }
134
135
136 END \
137 {
138 for (i = 0; i < lno - 1; ++i)
139 printf "%s%s\n", lines[i], (comma[i] ? "," : "");
140 print lines[i];
141 print "";
142 print "};";
143 print "";
144 printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1;
145 print "";
146 print "\
147 /* User-visible type of error codes. It is ok to use `int' or\n\
148 `kern_return_t' for these, but with `error_t' the debugger prints\n\
149 symbolic values. */";
150 print "#ifdef __USE_GNU";
151 print "typedef enum __error_t_codes error_t;"
152 print "#define __error_t_defined\t1"
153 print "#endif";
154 print "";
155 print "\
156 /* Return the current thread's location for `errno'.\n\
157 The syntax of this function allows redeclarations like `int errno'. */\n\
158 extern int *__errno_location (void) __THROW __attribute__ ((__const__));\n\
159 \n\
160 #define errno (*__errno_location ())\n\
161 ";
162 print "#endif /* <errno.h> included. */";
163 print "";
164 print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
165 print edom; print erange;
166 print "#endif /* <errno.h> not included and need math error codes. */";
167 }