(__pipe): Consider MIG_BAD_ID and EOPNOTSUPP as indications that the server port...
[glibc.git] / sysdeps / mach / hurd / errnos.awk
bloba8029987b5987853cb6b6fa1458dbdf3dde885ab
1 # Copyright (C) 1991, 1992, 1993, 1994, 1995 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 printf "/* This file generated by";
27 for (i = 0; i < ARGC; ++i)
28 printf " %s", ARGV[i];
29 printf ". */\n";
30 print "";
31 print "/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */";
32 print "#ifndef _HURD_ERRNO";
33 print "#define _HURD_ERRNO(n)\t((0x10 << 26) | ((n) & 0x3fff))";
34 print "#endif";
35 print "";
36 print "#ifdef _ERRNO_H\n";
37 print "enum __error_t_codes\n{";
38 errnoh = 0;
39 maxerrno = 0;
40 in_mach_errors = 0;
41 in_math = 0;
42 edom = erange = "";
43 print "#undef EDOM\n#undef ERANGE";
46 $1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
47 $1 == "@comment" && errnoh == 1 \
49 ++errnoh;
50 etext = "";
51 for (i = 3; i <= NF; ++i)
52 etext = etext " " $i;
53 next;
56 errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
57 { ++errnoh; e = $4; next; }
59 errnoh == 3 && $1 == "@comment" && $2 == "errno" {
60 errno = $3 + 0;
61 if (errno > maxerrno) maxerrno = errno;
62 if (e == "EWOULDBLOCK")
64 print "#define EWOULDBLOCK EAGAIN /* Operation would block */";
65 next;
67 x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
68 "_HURD_ERRNO (" errno ")"),
69 etext);
70 if (e == "EDOM")
71 edom = x;
72 else if (e == "ERANGE")
73 erange = x;
74 printf "\t%-16s= _HURD_ERRNO (%d),\n", e, errno;
75 print x;
76 next;
78 { errnoh=0 }
80 NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
82 in_mach_errors = 1;
83 print "\n\t/* Errors from <mach/message.h>. */";
85 NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
87 in_mach_errors = 1;
88 print "\n\t/* Errors from <mach/kern_return.h>. */";
89 next;
92 in_mach_errors && $2 == "MACH_IPC_COMPAT" \
94 in_mach_errors = 0;
97 in_mach_errors == 1 && NF == 3 && $1 == "#define" \
99 printf "\t%-32s= %s,\n", "E" $2, $3;
102 $1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
104 in_mig_errors = 1;
105 print "\n\t/* Errors from <mach/mig_errors.h>. */";
106 next;
108 in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
110 in_mig_errors = 0;
113 (in_mig_errors && $1 == "#define" && $3 <= -300) || \
114 (in_device_errors && $1 == "#define") \
116 printf "%-32s", sprintf ("\t%-24s= %s,", "E" $2, $3);
117 for (i = 4; i <= NF; ++i)
118 printf " %s", $i;
119 printf "\n";
122 $1 == "#define" && $2 == "D_SUCCESS" \
124 in_device_errors = 1;
125 print "\n\t/* Errors from <device/device_types.h>. */";
126 next;
128 in_device_errors && $1 == "#endif" \
130 in_device_errors = 0;
134 END \
136 print "";
137 print "};";
138 print "";
139 printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1;
140 print "";
141 print "\
142 /* User-visible type of error codes. It is ok to use `int' or\n\
143 `kern_return_t' for these, but with `error_t' the debugger prints\n\
144 symbolic values. */";
145 print "#ifdef __USE_GNU";
146 print "typedef enum __error_t_codes error_t;"
147 print "#endif";
148 print "";
149 print "/* errno is a per-thread variable. */";
150 print "#include <hurd/threadvar.h>";
151 print "#define errno (*__hurd_errno_location ())";
152 print "";
153 print "#endif /* <errno.h> included. */";
154 print "";
155 print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
156 print edom; print erange;
157 print "#endif /* <errno.h> not included and need math error codes. */";