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, $sysstub, $arch, $bits, $unistd, $outputdir, $havesyscall) = @args;
25 if (!open(UNISTD, '<', $unistd)) {
26 die "$0: $unistd: $!\n";
29 while ( defined($line = <UNISTD>) ) {
32 if ( $line =~ /^\#\s*define\s+__NR_([A-Za-z0-9_]+)\s+(.*\S)\s*$/ ) {
34 print STDERR "SYSCALL FOUND: $1\n" unless ( $quiet );
39 if (!open(HAVESYS, '>', $havesyscall)) {
40 die "$0: $havesyscall: $!\n";
43 print HAVESYS "#ifndef _KLIBC_HAVESYSCALL_H\n";
44 print HAVESYS "#define _KLIBC_HAVESYSCALL_H 1\n\n";
46 if (!open(FILE, '<', $file)) {
47 die "$0: $file: $!\n";
50 print "syscall-objs := ";
52 while ( defined($line = <FILE>) ) {
54 $line =~ s/\s*(|[\#;].*)$//; # Strip comments and trailing blanks
57 if ( $line =~ /^\s*(\<[^\>]+\>\s+|)([A-Za-z0-9_\*\s]+)\s+([A-Za-z0-9_,]+)(|\@[A-Za-z0-9_]+)(|\:\:[A-Za-z0-9_]+)\s*\(([^\:\)]*)\)\s*$/ ) {
68 die "$file:$.: Invalid architecture spec: <$archs>\n"
69 unless ( $archs =~ /^\<(|\?)(|\!)([^\>\!\?]*)\>/ );
74 $doit = $not || ($list eq '');
76 @list = split(/,/, $list);
77 foreach $a ( @list ) {
78 if ( $a eq $arch || $a eq $bits ) {
87 foreach $sn ( split(/,/, $snames) ) {
88 if ( defined $syscalls{$sn} ) {
93 if ( !defined($sname) ) {
95 die "$file:$.: Undefined system call: $snames\n";
101 if ( $fname eq '' ) {
107 @args = split(/\s*\,\s*/, $argv);
109 print HAVESYS "#define _KLIBC_HAVE_SYSCALL_${fname} ${sname}\n";
110 print " \\\n\t${fname}.o";
111 make_sysstub($outputdir, $fname, $type, $sname, $stype, @args);
113 die "$file:$.: Could not parse input: \"$line\"\n";
119 print HAVESYS "\n#endif\n";