You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

  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. use strict;
  9. if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
  10. print STDERR "GOARCH or GOOS not defined in environment\n";
  11. exit 1;
  12. }
  13. my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
  14. print <<EOF;
  15. // $command
  16. // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
  17. // +build $ENV{'GOARCH'},$ENV{'GOOS'}
  18. package unix
  19. const (
  20. EOF
  21. my $line = '';
  22. while(<>){
  23. if($line =~ /^(.*)\\$/) {
  24. # Handle continuation
  25. $line = $1;
  26. $_ =~ s/^\s+//;
  27. $line .= $_;
  28. } else {
  29. # New line
  30. $line = $_;
  31. }
  32. next if $line =~ /\\$/;
  33. if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
  34. my $num = $1;
  35. my $proto = $6;
  36. my $compat = $8;
  37. my $name = "$7_$9";
  38. $name = "$7_$11" if $11 ne '';
  39. $name =~ y/a-z/A-Z/;
  40. if($compat eq '' || $compat eq '30' || $compat eq '50') {
  41. print " $name = $num; // $proto\n";
  42. }
  43. }
  44. }
  45. print <<EOF;
  46. )
  47. EOF