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 # Check that we are using the new build system if we should
14 if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
15 print STDERR "In the new build system, mksysnum should not be called directly.\n";
16 print STDERR "See README.md\n";
20 my $command = "$0 ". join(' ', @ARGV);
24 // Code generated by the command above; see README.md. DO NOT EDIT.
26 // +build $ENV{'GOARCH'},$ENV{'GOOS'}
36 my ($name, $num) = @_;
38 # ignore deprecated syscalls that are no longer implemented
39 # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
43 $num = $num + $offset;
44 print " SYS_$name = $num;\n";
48 open(CC, "$ENV{'CC'} -E -dD @ARGV |") || die "can't run $ENV{'CC'}";
50 if(/^#define __NR_Linux\s+([0-9]+)/){
51 # mips/mips64: extract offset
54 elsif(/^#define __NR(\w*)_SYSCALL_BASE\s+([0-9]+)/){
58 elsif(/^#define __NR_syscalls\s+/) {
59 # ignore redefinitions of __NR_syscalls
61 elsif(/^#define __NR_(\w*)Linux_syscalls\s+/) {
62 # mips/mips64: ignore definitions about the number of syscalls
64 elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
68 elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
72 elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
75 elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){
78 elsif(/^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE \+ ([0-9]+)/){