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 @includelist = (); # Include directories
17 my($fh) = new FileHandle
;
18 my($line, $error, $msg);
22 print STDERR
"opening $file\n" unless ( $quiet );
25 foreach $root ( @includelist ) {
26 if ( $fh->open($root.'//'.$file, '<') ) {
33 die "$0: Cannot find file $file\n";
36 while ( defined($line = <$fh>) ) {
38 if ( $line =~ /^\#\s*endif/ ) {
40 } elsif ( $line =~ /^\#\sif/ ) {
44 if ( $line =~ /^\#\s*define\s+([A-Z0-9_]+)\s+([0-9]+)\s*\/\
*\s
*(.*\S
)\s
*\
*\
// ) {
48 print STDERR
"$error ($errno) => \"$msg\"\n" unless ( $quiet );
49 $errors{$errno} = $error;
50 $errmsg{$errno} = $msg;
51 $maxerr = $errno if ( $errno > $maxerr );
52 } elsif ( $line =~ /^\#\s*include\s+[\<\"](.*)[\>\"]/ ) {
54 } elsif ( $line =~ /^\#\s*ifdef\s+__KERNEL__/ ) {
60 print STDERR
"closing $file\n" unless ( $quiet );
63 $v = $ENV{'KBUILD_VERBOSE'};
64 $quiet = defined($v) ?
!$v : 0;
66 foreach $arg ( @ARGV ) {
69 } elsif ( $arg =~ /^-(errlist|errnos|maxerr)$/ ) {
71 } elsif ( $arg =~ '^\-I' ) {
72 push(@includelist, "$'");
78 parse_file
('errno.h');
80 if ( $type eq '-errlist' ) {
81 print "#include <errno.h>\n";
82 printf "const int sys_nerr = %d;\n", $maxerr+1;
83 printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
84 foreach $e ( sort(keys(%errors)) ) {
85 printf " [%s] = \"%s\",\n", $errors{$e}, $errmsg{$e};
88 } elsif ( $type eq '-errnos' ) {
89 print "#include <errno.h>\n";
90 printf "const int sys_nerr = %d;\n", $maxerr+1;
91 printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
92 foreach $e ( sort(keys(%errors)) ) {
93 printf " [%s] = \"%s\",\n", $errors{$e}, $errors{$e};
96 } elsif ( $type eq '-maxerr' ) {