#!/usr/bin/env perl
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# Generate system call table for OpenBSD from master list
# (for example, /usr/src/sys/kern/syscalls.master).
use strict;
my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
print <<EOF;
// $command
// Code generated by the command above; DO NOT EDIT.
package syscall
const (
EOF
my $line = '';
while(<>){
	chomp;
	if($line =~ /^(.*)\\$/) {
		# Handle continuation	
		$line =~ s/\\$//;
		s/^\s+//;
	} else {                
		# New line
		$line = '';
	}
	$line .= $_;
	next if $line =~ /\\$/;
	if($line =~ /^([0-9]+)\s+(?:STD|NOERR)\s+(?:MODULAR\s+)?(?:RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
		my $num = $1;
		my $proto = $2;
		my $compat = $4;
		my $name = "$3_$5";
		$name = "$3_$8" if $8 ne '';
		$name =~ y/a-z/A-Z/;
		if($compat eq '' || $compat eq '30' || $compat eq '50') {
			print " $name = $num; // $proto\n";
		}
	}
}
print <<EOF;
)
EOF
