diff options
Diffstat (limited to 'sysdeps/mach/hurd/errnos.awk')
-rw-r--r-- | sysdeps/mach/hurd/errnos.awk | 107 |
1 files changed, 29 insertions, 78 deletions
diff --git a/sysdeps/mach/hurd/errnos.awk b/sysdeps/mach/hurd/errnos.awk index 1fdca40d38..c5d33b5d8f 100644 --- a/sysdeps/mach/hurd/errnos.awk +++ b/sysdeps/mach/hurd/errnos.awk @@ -15,31 +15,18 @@ # License along with the GNU C Library; if not, see # <http://www.gnu.org/licenses/>. -# errno.texinfo contains lines like: -# @errno{ENOSYS, 123, Function not implemented} +# Generate bits/errno.h from errnos.texi and a number of Mach headers. +# This script must be kept in sync with stdlib/make-errno-constants.awk +# and hurd-add-errno-constants.awk. BEGIN { - print "/* This file generated by errnos.awk from"; - for (i = 1; i < ARGC; i++) - { - arg = ARGV[i]; - sub(/.*(manual|include)\//, "", arg) - print " " arg; - } - print " Do not edit this file; edit errnos.awk and regenerate it. */"; - print ""; - print "#ifndef _BITS_ERRNO_H"; - print "#define _BITS_ERRNO_H 1"; - print ""; - print "#if !defined _ERRNO_H"; - print "# error \"Never include <bits/errno.h> directly; use <errno.h> instead.\""; - print "#endif"; - - maxerrno = 0; - maxerrlen = 0; - in_mach_errors = ""; - seq = 0; - } + maxerrno = 0; + maxerrlen = 0; + in_mach_errors = ""; + in_mig_errors = 0; + in_device_errors = 0; + seq = 0; +} /^@errno\{/ \ { @@ -147,73 +134,37 @@ in_device_errors && $1 == "#endif" \ in_device_errors = 0; } -function print_errno_enum(maxseq) -{ - print ""; - print "#ifndef __ASSEMBLER__"; - print ""; - print "enum __error_t_codes"; - print "{"; - print " /* The value zero always means success and it is perfectly fine"; - print " for code to use 0 explicitly (or implicitly, e.g. via Boolean"; - print " coercion.) Having an enum entry for zero both makes the"; - print " debugger print the name for error_t-typed zero values, and"; - print " prevents the compiler from issuing warnings about 'case 0:'"; - print " in a switch on an error_t-typed value. */"; - printf(" %-*s = 0,\n", maxerrlen, "ESUCCESS"); - - print ""; - print " /* The Hurd uses Mach error system 0x10, subsystem 0. */"; - for (i = 0; i < maxseq; i++) +END { + print "/* This file generated by errnos.awk from"; + for (i = 1; i < ARGC; i++) { - if (i in annot) - print annot[i]; - else if (i in etexts && etexts[i] != "") - printf(" %-*s = %s,\t/* %s */\n", - maxerrlen, econsts[i], errnos[i], etexts[i]); - else if (errnos[i] != "EAGAIN") - printf(" %-*s = %s,\n", maxerrlen, econsts[i], errnos[i]); + arg = ARGV[i]; + sub(/.*(manual|include)\//, "", arg) + print " " arg; } - - print ""; - print " /* Because the C standard requires that errno have type 'int'," - print " this enumeration must be a signed type. */"; - print " __FORCE_ERROR_T_CODES_SIGNED = -1"; - print "};"; + print " Do not edit this file; edit errnos.awk and regenerate it. */"; print ""; - print "/* User-visible type of error codes. It is ok to use 'int' or"; - print " 'kern_return_t' for these, but with 'error_t' the debugger prints"; - print " symbolic values. */"; - print "# if !defined __error_t_defined && defined __USE_GNU"; - print "# define __error_t_defined 1"; - print "typedef enum __error_t_codes error_t;" - print "# endif"; + print "#ifndef _BITS_ERRNO_H"; + print "#define _BITS_ERRNO_H 1"; print ""; - print "#endif /* not __ASSEMBLER__ */"; -} - -function print_errno_defines(maxseq) -{ + print "#if !defined _ERRNO_H"; + print "# error \"Never include <bits/errno.h> directly; use <errno.h> instead.\""; + print "#endif"; print ""; - print "/* The C standard requires that all of the E-constants be" - print " defined as macros. */" + print "/* The Hurd uses Mach error system 0x10, subsystem 0. */"; print ""; - for (i = 0; i < maxseq; i++) + for (i = 0; i < seq; i++) { if (i in annot) print annot[i]; + else if (i in etexts && etexts[i] != "") + printf("#define %-*s %s\t/* %s */\n", + maxerrlen, econsts[i], errnos[i], etexts[i]); else printf("#define %-*s %s\n", maxerrlen, econsts[i], errnos[i]); } print ""; printf("#define _HURD_ERRNOS %d\n", maxerrno+1); + print ""; + print "#endif /* bits/errno.h. */"; } - -END \ - { - print_errno_enum(seq); - print_errno_defines(seq); - - print ""; - print "#endif /* bits/errno.h. */"; - } |