mksysnum_linux.pl 633 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. use strict;
  6. my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
  7. print <<EOF;
  8. // $command
  9. // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
  10. package unix
  11. const(
  12. EOF
  13. sub fmt {
  14. my ($name, $num) = @_;
  15. $name =~ y/a-z/A-Z/;
  16. print " SYS_$name = $num;\n";
  17. }
  18. my $prev;
  19. while(<>){
  20. if(/^#define __NR_(\w+)\s+([0-9]+)/){
  21. $prev = $2;
  22. fmt($1, $2);
  23. }
  24. elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
  25. fmt($1, $prev+$2)
  26. }
  27. }
  28. print <<EOF;
  29. )
  30. EOF