2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / errnos.awk
blobcefa24f0ae42d5f7d42f80ff0ae2321a3f5a1a6e
1 # Copyright (C) 1991,92,93,94,95,96,97,2000,01,02
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
20 # errno.texinfo contains lines like:
21 # @comment errno.h
22 # @comment POSIX.1: Function not implemented
23 # @deftypevr Macro int ENOSYS
24 # @comment errno 123
26 BEGIN {
27 print "/* This file generated by errnos.awk. */";
28 print "";
29 print "/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */";
30 print "#ifndef _HURD_ERRNO";
31 print "#define _HURD_ERRNO(n)\t((0x10 << 26) | ((n) & 0x3fff))";
32 print "#endif";
33 print "";
34 print "#ifdef _ERRNO_H\n";
35 print "enum __error_t_codes\n{";
36 errnoh = 0;
37 maxerrno = 0;
38 in_mach_errors = "";
39 in_math = 0;
40 edom = erange = "";
41 print "#undef EDOM\n#undef ERANGE";
42 lno = 0;
45 $1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
46 $1 == "@comment" && errnoh == 1 \
48 ++errnoh;
49 etext = "";
50 for (i = 3; i <= NF; ++i)
51 etext = etext " " $i;
52 next;
55 errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
56 { ++errnoh; e = $4; next; }
58 errnoh == 3 && $1 == "@comment" && $2 == "errno" {
59 if (e == "EWOULDBLOCK")
61 lines[lno++]="#define EWOULDBLOCK EAGAIN /* Operation would block */";
62 next;
64 errno = $3 + 0;
65 if (errno == 0)
66 next;
67 if (errno > maxerrno) maxerrno = errno;
68 x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
69 "_HURD_ERRNO (" errno ")"),
70 etext);
71 if (e == "EDOM")
72 edom = x;
73 else if (e == "ERANGE")
74 erange = x;
75 comma[lno] = 1;
76 lines[lno++] = sprintf("\t%-16s= _HURD_ERRNO (%d)", e, errno);
77 lines[lno++] = x;
78 next;
80 { errnoh=0 }
82 NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
84 in_mach_errors = FILENAME;
85 lines[lno++] = "\n\t/* Errors from <mach/message.h>. */";
87 NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
89 in_mach_errors = FILENAME;
90 lines[lno++] = "\n\t/* Errors from <mach/kern_return.h>. */";
91 next;
94 in_mach_errors != "" && $2 == "MACH_IPC_COMPAT" \
96 in_mach_errors = "";
99 in_mach_errors == FILENAME && NF == 3 && $1 == "#define" \
101 comma[lno] = 1;
102 lines[lno++] = sprintf("\t%-32s= %s", "E" $2, $3);
105 $1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
107 in_mig_errors = 1;
108 lines[lno++] = "\n\t/* Errors from <mach/mig_errors.h>. */";
109 next;
111 in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
113 in_mig_errors = 0;
116 (in_mig_errors && $1 == "#define" && $3 <= -300) || \
117 (in_device_errors && $1 == "#define" && /D_/ && NF > 3) \
119 comment = "";
120 for (i = 4; i <= NF; ++i)
121 comment = comment " " $i;
122 comma[lno] = 1;
123 lines[lno++] = sprintf("%-32s", sprintf ("\t%-24s= %s", "E" $2, $3)) comment;
126 $1 == "#define" && $2 == "D_SUCCESS" \
128 in_device_errors = 1;
129 lines[lno++] = "\n\t/* Errors from <device/device_types.h>. */";
130 next;
132 in_device_errors && $1 == "#endif" \
134 in_device_errors = 0;
138 END \
140 for (i = 0; i < lno - 1; ++i)
141 printf "%s%s\n", lines[i], (comma[i] ? "," : "");
142 print lines[i];
143 print "";
144 print "};";
145 print "";
146 printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1;
147 print "";
148 print "\
149 /* User-visible type of error codes. It is ok to use `int' or\n\
150 `kern_return_t' for these, but with `error_t' the debugger prints\n\
151 symbolic values. */";
152 print "#ifdef __USE_GNU";
153 print "typedef enum __error_t_codes error_t;"
154 print "#define __error_t_defined\t1"
155 print "#endif";
156 print "";
157 print "\
158 /* Return the current thread's location for `errno'.\n\
159 The syntax of this function allows redeclarations like `int errno'. */\n\
160 extern int *__errno_location (void) __THROW __attribute__ ((__const__));\n\
162 #define errno (*__errno_location ())\n\
164 print "#endif /* <errno.h> included. */";
165 print "";
166 print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
167 print edom; print erange;
168 print "#endif /* <errno.h> not included and need math error codes. */";