Sun May 12 11:16:58 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / sysdeps / mach / hurd / errnos.awk
blob24a01ba9352202c18a0bc21f1eabdf1a31cbc5ab
1 # Copyright (C) 1991, 92, 93, 94, 95, 96 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 Library General Public License
6 # as published by the Free Software Foundation; either version 2 of
7 # 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 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If
16 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 # Cambridge, MA 02139, USA.
19 # errno.texinfo contains lines like:
20 # @comment errno.h
21 # @comment POSIX.1: Function not implemented
22 # @deftypevr Macro int ENOSYS
23 # @comment errno 123
25 BEGIN {
26 print "/* This file generated by errnos.awk. */";
27 print "";
28 print "/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */";
29 print "#ifndef _HURD_ERRNO";
30 print "#define _HURD_ERRNO(n)\t((0x10 << 26) | ((n) & 0x3fff))";
31 print "#endif";
32 print "";
33 print "#ifdef _ERRNO_H\n";
34 print "enum __error_t_codes\n{";
35 errnoh = 0;
36 maxerrno = 0;
37 in_mach_errors = "";
38 in_math = 0;
39 edom = erange = "";
40 print "#undef EDOM\n#undef ERANGE";
43 $1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
44 $1 == "@comment" && errnoh == 1 \
46 ++errnoh;
47 etext = "";
48 for (i = 3; i <= NF; ++i)
49 etext = etext " " $i;
50 next;
53 errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
54 { ++errnoh; e = $4; next; }
56 errnoh == 3 && $1 == "@comment" && $2 == "errno" {
57 errno = $3 + 0;
58 if (errno > maxerrno) maxerrno = errno;
59 if (e == "EWOULDBLOCK")
61 print "#define EWOULDBLOCK EAGAIN /* Operation would block */";
62 next;
64 x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
65 "_HURD_ERRNO (" errno ")"),
66 etext);
67 if (e == "EDOM")
68 edom = x;
69 else if (e == "ERANGE")
70 erange = x;
71 printf "\t%-16s= _HURD_ERRNO (%d),\n", e, errno;
72 print x;
73 next;
75 { errnoh=0 }
77 NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
79 in_mach_errors = FILENAME;
80 print "\n\t/* Errors from <mach/message.h>. */";
82 NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
84 in_mach_errors = FILENAME;
85 print "\n\t/* Errors from <mach/kern_return.h>. */";
86 next;
89 in_mach_errors != "" && $2 == "MACH_IPC_COMPAT" \
91 in_mach_errors = "";
94 in_mach_errors == FILENAME && NF == 3 && $1 == "#define" \
96 printf "\t%-32s= %s,\n", "E" $2, $3;
99 $1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
101 in_mig_errors = 1;
102 print "\n\t/* Errors from <mach/mig_errors.h>. */";
103 next;
105 in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
107 in_mig_errors = 0;
110 (in_mig_errors && $1 == "#define" && $3 <= -300) || \
111 (in_device_errors && $1 == "#define") \
113 printf "%-32s", sprintf ("\t%-24s= %s,", "E" $2, $3);
114 for (i = 4; i <= NF; ++i)
115 printf " %s", $i;
116 printf "\n";
119 $1 == "#define" && $2 == "D_SUCCESS" \
121 in_device_errors = 1;
122 print "\n\t/* Errors from <device/device_types.h>. */";
123 next;
125 in_device_errors && $1 == "#endif" \
127 in_device_errors = 0;
131 END \
133 print "";
134 print "};";
135 print "";
136 printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1;
137 print "";
138 print "\
139 /* User-visible type of error codes. It is ok to use `int' or\n\
140 `kern_return_t' for these, but with `error_t' the debugger prints\n\
141 symbolic values. */";
142 print "#ifdef __USE_GNU";
143 print "typedef enum __error_t_codes error_t;"
144 print "#define __error_t_defined\t1"
145 print "#endif";
146 print "";
147 print "/* errno is a per-thread variable. */";
148 print "#include <hurd/threadvar.h>";
149 print "#define errno (*__hurd_errno_location ())";
150 print "";
151 print "#endif /* <errno.h> included. */";
152 print "";
153 print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
154 print edom; print erange;
155 print "#endif /* <errno.h> not included and need math error codes. */";