Home | History | Annotate | Download | only in unix
      1 #!/usr/bin/env perl
      2 # Copyright 2009 The Go Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style
      4 # license that can be found in the LICENSE file.
      5 #
      6 # Generate system call table for OpenBSD from master list
      7 # (for example, /usr/src/sys/kern/syscalls.master).
      8 
      9 use strict;
     10 
     11 if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
     12 	print STDERR "GOARCH or GOOS not defined in environment\n";
     13 	exit 1;
     14 }
     15 
     16 my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
     17 
     18 print <<EOF;
     19 // $command
     20 // Code generated by the command above; see README.md. DO NOT EDIT.
     21 
     22 // +build $ENV{'GOARCH'},$ENV{'GOOS'}
     23 
     24 package unix
     25 
     26 const (
     27 EOF
     28 
     29 my $line = '';
     30 while(<>){
     31 	if($line =~ /^(.*)\\$/) {
     32 		# Handle continuation
     33 		$line = $1;
     34 		$_ =~ s/^\s+//;
     35 		$line .= $_;
     36 	} else {
     37 		# New line
     38 		$line = $_;
     39 	}
     40 	next if $line =~ /\\$/;
     41 	if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
     42 		my $num = $1;
     43 		my $proto = $6;
     44 		my $compat = $8;
     45 		my $name = "$7_$9";
     46 
     47 		$name = "$7_$11" if $11 ne '';
     48 		$name =~ y/a-z/A-Z/;
     49 
     50 		if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') {
     51 			print "	$name = $num;  // $proto\n";
     52 		}
     53 	}
     54 }
     55 
     56 print <<EOF;
     57 )
     58 EOF
     59