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.
8 if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
9 print STDERR "GOARCH or GOOS not defined in environment\n";
13 my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
17 // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
19 // +build $ENV{'GOARCH'},$ENV{'GOOS'}
29 my ($name, $num) = @_;
31 # ignore deprecated syscalls that are no longer implemented
32 # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
36 $num = $num + $offset;
37 print " SYS_$name = $num;\n";
41 open(GCC, "gcc -E -dD @ARGV |") || die "can't run gcc";
43 if(/^#define __NR_Linux\s+([0-9]+)/){
44 # mips/mips64: extract offset
47 elsif(/^#define __NR(\w*)_SYSCALL_BASE\s+([0-9]+)/){
51 elsif(/^#define __NR_syscalls\s+/) {
52 # ignore redefinitions of __NR_syscalls
54 elsif(/^#define __NR_(\w*)Linux_syscalls\s+/) {
55 # mips/mips64: ignore definitions about the number of syscalls
57 elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
61 elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
65 elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
68 elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){
71 elsif(/^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE \+ ([0-9]+)/){