From f2b45db8104795e59cb8dc842b8ab594effc3c2a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 13 May 2015 15:28:32 -0700 Subject: [PATCH] unix: update generation scripts for arm64/ppc64 This applies the following CLs from the syscall package: http://golang.org/cl/9962 http://golang.org/cl/9966 http://golang.org/cl/9924 It also adds arm64/ppc64 support to mkall.sh and mksysnum_linux.pl. Change-Id: I84fbfde2a2876dbf6d16c6159e847195c274b396 Reviewed-on: https://go-review.googlesource.com/10037 Reviewed-by: Rob Pike --- unix/mkall.sh | 30 ++++++++++++++++++++++++++++-- unix/mkerrors.sh | 2 ++ unix/mksysnum_linux.pl | 17 +++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/unix/mkall.sh b/unix/mkall.sh index 4632f894..d00ab2ff 100755 --- a/unix/mkall.sh +++ b/unix/mkall.sh @@ -107,6 +107,7 @@ case "$#" in exit 2 esac +GOOSARCH_in=syscall_$GOOSARCH.go case "$GOOSARCH" in _* | *_ | _) echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 @@ -173,7 +174,32 @@ linux_amd64) linux_arm) mkerrors="$mkerrors" mksyscall="./mksyscall.pl -l32 -arm" - mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl" + mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_arm64) + unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1) + if [ "$unistd_h" = "" ]; then + echo >&2 cannot find unistd_64.h + exit 1 + fi + mksysnum="./mksysnum_linux.pl $unistd_h" + # Let the type of C char be singed for making the bare syscall + # API consistent across over platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +linux_ppc64) + GOOSARCH_in=syscall_linux_ppc64x.go + unistd_h=/usr/include/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_ppc64le) + GOOSARCH_in=syscall_linux_ppc64x.go + unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" mktypes="GOARCH=$GOARCH go tool cgo -godefs" ;; netbsd_386) @@ -226,7 +252,7 @@ esac syscall_goos="syscall_bsd.go $syscall_goos" ;; esac - if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"; fi + if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi ;; esac if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi diff --git a/unix/mkerrors.sh b/unix/mkerrors.sh index 29813778..1490b39f 100755 --- a/unix/mkerrors.sh +++ b/unix/mkerrors.sh @@ -88,7 +88,9 @@ includes_FreeBSD=' includes_Linux=' #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE +#ifndef __LP64__ #define _FILE_OFFSET_BITS 64 +#endif #define _GNU_SOURCE #include diff --git a/unix/mksysnum_linux.pl b/unix/mksysnum_linux.pl index 5204378f..8c8b22e6 100755 --- a/unix/mksysnum_linux.pl +++ b/unix/mksysnum_linux.pl @@ -18,13 +18,26 @@ EOF sub fmt { my ($name, $num) = @_; + if($num > 999){ + # ignore deprecated syscalls that are no longer implemented + # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 + return; + } $name =~ y/a-z/A-Z/; print " SYS_$name = $num;\n"; } my $prev; -while(<>){ - if(/^#define __NR_(\w+)\s+([0-9]+)/){ +open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; +while(){ + if(/^#define __NR_syscalls\s+/) { + # ignore redefinitions of __NR_syscalls + } + elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ + $prev = $2; + fmt($1, $2); + } + elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ $prev = $2; fmt($1, $2); }