3 # This creates sys_errlist from <asm/errno.h> through somewhat
4 # heuristic matching. It presumes the relevant entries are of the form
5 # #define Exxxx <integer> /* comment */
13 $rootdir = '../linux/include/'; # Must have trailing /
17 my($fh) = new FileHandle;
18 my($line, $error, $msg);
21 $file = $rootdir.$file;
23 print STDERR "opening $file\n";
25 if ( !($fh->open("< ".$file)) ) {
26 die "$0: cannot open $file\n";
29 while ( defined($line = <$fh>) ) {
31 if ( $line =~ /^\#\s*endif/ ) {
33 } elsif ( $line =~ /^\#\sif/ ) {
37 if ( $line =~ /^\#\s*define\s+([A-Z0-9_]+)\s+([0-9]+)\s*\/\*\s*(.*\S)\s*\*\// ) {
41 print STDERR "$error ($errno) => \"$msg\"\n";
42 $errors{$errno} = $error;
43 $errmsg{$errno} = $msg;
44 $maxerr = $errno if ( $errno > $maxerr );
45 } elsif ( $line =~ /^\#\s*include\s+[\<\"](.*)[\>\"]/ ) {
47 } elsif ( $line =~ /^\#\s*ifdef\s+__KERNEL__/ ) {
53 print STDERR "closing $file\n";
56 parse_file('linux/errno.h');
60 if ( $type eq '-errlist' ) {
61 print "#include <errno.h>\n";
62 printf "const int sys_nerr = %d;\n", $maxerr+1;
63 printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
64 foreach $e ( sort(keys(%errors)) ) {
65 printf " [%s] = \"%s\",\n", $errors{$e}, $errmsg{$e};
68 } elsif ( $type eq '-errnos' ) {
69 print "#include <errno.h>\n";
70 printf "const int sys_nerr = %d;\n", $maxerr+1;
71 printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
72 foreach $e ( sort(keys(%errors)) ) {
73 printf " [%s] = \"%s\",\n", $errors{$e}, $errors{$e};
76 } elsif ( $type eq '-maxerr' ) {