3 # Script to parse the SYSCALLS file and generate appropriate
6 $v = $ENV{'KBUILD_VERBOSE'};
7 $quiet = defined($v) ? !$v : 0;
15 die "$0: Unknown option: $arg\n";
21 ($file, $arch, $bits, $unistd, $havesyscall) = @args;
23 require "arch/$arch/sysstub.ph";
25 if (!open(UNISTD, '<', $unistd)) {
26 die "$0: $unistd: $!\n";
28 while ( defined($line = <UNISTD>) ) {
31 if ( $line =~ /^\#\s*define\s+__NR_([A-Za-z0-9_]+)\s+(.*\S)\s*$/ ) {
33 print STDERR "SYSCALL FOUND: $1\n" unless ( $quiet );
38 if (!open(HAVESYS, '>', $havesyscall)) {
39 die "$0: $havesyscall: $!\n";
42 print HAVESYS "#ifndef _KLIBC_HAVESYSCALL_H\n";
43 print HAVESYS "#define _KLIBC_HAVESYSCALL_H 1\n\n";
45 if (!open(FILE, '<', $file)) {
46 die "$0: $file: $!\n";
49 while ( defined($line = <FILE>) ) {
51 $line =~ s/\s*(|[\#;].*)$//; # Strip comments and trailing blanks
54 if ( $line =~ /^\s*(\<[^\>]+\>\s+|)([A-Za-z0-9_\*\s]+)\s+([A-Za-z0-9_,]+)(|\@[A-Za-z0-9_]+)(|\:\:[A-Za-z0-9_]+)\s*\(([^\:\)]*)\)\s*$/ ) {
65 die "$file:$.: Invalid architecture spec: <$archs>\n"
66 unless ( $archs =~ /^\<(|\?)(|\!)([^\>\!\?]*)\>/ );
71 $doit = $not || ($list eq '');
73 @list = split(/,/, $list);
74 foreach $a ( @list ) {
75 if ( $a eq $arch || $a eq $bits ) {
84 foreach $sn ( split(/,/, $snames) ) {
85 if ( defined $syscalls{$sn} ) {
90 if ( !defined($sname) ) {
92 die "$file:$.: Undefined system call: $snames\n";
104 @args = split(/\s*\,\s*/, $argv);
106 print HAVESYS "#define _KLIBC_HAVE_SYSCALL_${fname} ${sname}\n";
107 make_sysstub($fname, $type, $sname, $stype, @args);
109 die "$file:$.: Could not parse input: \"$line\"\n";
113 print HAVESYS "\n#endif\n";