rsc.io/go@v0.0.0-20150416155037-e040fd465409/src/syscall/mksysnum_linux.pl (about) 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 use strict; 7 8 my $command = "mksysnum_linux.pl ". join(' ', @ARGV); 9 10 print <<EOF; 11 // $command 12 // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT 13 14 package syscall 15 16 const( 17 EOF 18 19 sub fmt { 20 my ($name, $num) = @_; 21 if($num > 999){ 22 # ignore depricated syscalls that are no longer implemented 23 # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 24 return; 25 } 26 $name =~ y/a-z/A-Z/; 27 print " SYS_$name = $num;\n"; 28 } 29 30 my $prev; 31 while(<>){ 32 if(/^#define __NR_syscalls\s+/) { 33 # ignore redefinitions of __NR_syscalls 34 } 35 elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 36 $prev = $2; 37 fmt($1, $2); 38 } 39 elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 40 $prev = $2; 41 fmt($1, $2); 42 } 43 elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 44 fmt($1, $prev+$2) 45 } 46 } 47 48 print <<EOF; 49 ) 50 EOF