mksysnum_netbsd.pl 1.0 KB

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