diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-10-05 20:11:24 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-10-05 20:11:24 +0000 |
commit | 504cafd97cd40223dac4beb4a28cb85368cff5b9 (patch) | |
tree | 153fa1d9d2a0ab481ba54a9f2f4ed6e311e2a5bf /libgo | |
parent | 5055f108385c076346b3b279788dc0129549b11f (diff) | |
parent | 0d48e8779c6a9ac88f5efd1b4a2d40f43ef75faf (diff) | |
download | gcc-504cafd97cd40223dac4beb4a28cb85368cff5b9.zip gcc-504cafd97cd40223dac4beb4a28cb85368cff5b9.tar.gz gcc-504cafd97cd40223dac4beb4a28cb85368cff5b9.tar.bz2 |
Merge from trunk revision 264887.
From-SVN: r264890
Diffstat (limited to 'libgo')
33 files changed, 597 insertions, 87 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 373dd0c..699e10d 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -532,6 +532,14 @@ s-version: Makefile $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ +cpugen.go: s-cpu; @true +s-cpu: Makefile + rm -f cpugen.go.tmp + echo "package cpu" > cpugen.go.tmp + echo "const CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp + $(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go + $(STAMP) $@ + objabi.go: s-objabi; @true s-objabi: Makefile rm -f objabi.go.tmp @@ -963,6 +971,9 @@ runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline extra_go_files_runtime_internal_sys = version.go runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys) +extra_go_files_internal_cpu = cpugen.go +internal/cpu.lo.dep: $(extra_go_files_internal_cpu) + extra_go_files_internal_goroot = zstdpkglist.go internal/goroot.lo.dep: $(extra_go_files_internal_goroot) diff --git a/libgo/Makefile.in b/libgo/Makefile.in index dfc2c66..10b11e0 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -1002,6 +1002,7 @@ runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime # Also use -fno-inline to get better results from the memory profiler. runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline extra_go_files_runtime_internal_sys = version.go +extra_go_files_internal_cpu = cpugen.go extra_go_files_internal_goroot = zstdpkglist.go extra_go_files_go_types = gccgosizes.go extra_go_files_cmd_internal_objabi = objabi.go @@ -2759,6 +2760,14 @@ s-version: Makefile $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ +cpugen.go: s-cpu; @true +s-cpu: Makefile + rm -f cpugen.go.tmp + echo "package cpu" > cpugen.go.tmp + echo "const CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp + $(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go + $(STAMP) $@ + objabi.go: s-objabi; @true s-objabi: Makefile rm -f objabi.go.tmp @@ -2957,6 +2966,7 @@ $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))) runtime.lo.dep: $(extra_go_files_runtime) syscall.lo.dep: $(extra_go_files_syscall) runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys) +internal/cpu.lo.dep: $(extra_go_files_internal_cpu) internal/goroot.lo.dep: $(extra_go_files_internal_goroot) go/types.lo.dep: $(extra_go_files_go_types) cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi) diff --git a/libgo/config.h.in b/libgo/config.h.in index de57d0c..d47969d 100644 --- a/libgo/config.h.in +++ b/libgo/config.h.in @@ -141,6 +141,9 @@ /* Define to 1 if you have the `matherr' function. */ #undef HAVE_MATHERR +/* Define to 1 if you have the `memmem' function. */ +#undef HAVE_MEMMEM + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H diff --git a/libgo/configure b/libgo/configure index 7166f94..356ad2b 100755 --- a/libgo/configure +++ b/libgo/configure @@ -13685,7 +13685,19 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=386 else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __ILP32__ +#error x32 +#endif +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : GOARCH=amd64 +else + GOARCH=amd64p32 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; @@ -14769,7 +14781,7 @@ else fi -for ac_func in strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr +for ac_func in strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/libgo/configure.ac b/libgo/configure.ac index 1c19275..e2193a5 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -252,8 +252,13 @@ changequote([,])dnl #ifdef __x86_64__ #error 64-bit #endif], -[GOARCH=386], -[GOARCH=amd64]) + [GOARCH=386], + AC_COMPILE_IFELSE([ +#ifdef __ILP32__ +#error x32 +#endif], + [GOARCH=amd64], + [GOARCH=amd64p32])) ;; ia64-*-*) GOARCH=ia64 @@ -539,7 +544,7 @@ AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes) -AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr) +AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem) AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes) diff --git a/libgo/go/cmd/go/internal/load/pkg.go b/libgo/go/cmd/go/internal/load/pkg.go index 0579fd5..b6c9037 100644 --- a/libgo/go/cmd/go/internal/load/pkg.go +++ b/libgo/go/cmd/go/internal/load/pkg.go @@ -953,8 +953,14 @@ func disallowInternal(srcDir string, importer *Package, importerPath string, p * } // We can't check standard packages with gccgo. - if cfg.BuildContext.Compiler == "gccgo" && p.Standard { - return p + if cfg.BuildContext.Compiler == "gccgo" { + if importer == nil { + if p.Standard { + return p + } + } else if importer.Standard || strings.HasPrefix(importerPath, "cmd/") { + return p + } } // The stack includes p.ImportPath. diff --git a/libgo/go/cmd/go/script_test.go b/libgo/go/cmd/go/script_test.go index 02cb17b..9e958e0 100644 --- a/libgo/go/cmd/go/script_test.go +++ b/libgo/go/cmd/go/script_test.go @@ -78,6 +78,7 @@ var extraEnvKeys = []string{ // For gccgo testing. "GO_TESTING_GOTOOLS", + "GCCGO", "GCCGOTOOLDIR", } diff --git a/libgo/go/cmd/go/testdata/script/mod_internal.txt b/libgo/go/cmd/go/testdata/script/mod_internal.txt index 84e77c6..72706fd 100644 --- a/libgo/go/cmd/go/testdata/script/mod_internal.txt +++ b/libgo/go/cmd/go/testdata/script/mod_internal.txt @@ -16,11 +16,11 @@ stderr 'use of internal package golang.org/x/.* not allowed' # Internal packages in the standard library should not leak into modules. ! go build ./fromstd -[!gccgo] stderr 'use of internal package internal/testenv not allowed' +stderr 'use of internal package internal/testenv not allowed' # Packages found via standard-library vendoring should not leak. ! go build ./fromstdvendor -[!gccgo] stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' +stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' env GO111MODULE=off ! go build ./fromstdvendor diff --git a/libgo/go/hash/crc32/crc32_amd64p32.go b/libgo/go/hash/crc32/crc32_amd64p32.go index 1ec44cb4..f61b801 100644 --- a/libgo/go/hash/crc32/crc32_amd64p32.go +++ b/libgo/go/hash/crc32/crc32_amd64p32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package crc32 import "internal/cpu" diff --git a/libgo/go/internal/bytealg/bytealg.c b/libgo/go/internal/bytealg/bytealg.c index 39c060f..988dfaa 100644 --- a/libgo/go/internal/bytealg/bytealg.c +++ b/libgo/go/internal/bytealg/bytealg.c @@ -10,6 +10,33 @@ #include "runtime.h" #include "array.h" +#ifndef HAVE_MEMMEM + +#define memmem goMemmem + +static const void *goMemmem(const void *in, size_t inl, const void *s, size_t sl) { + const char *p; + char first; + const char *stop; + + if (sl == 0) { + return in; + } + if (inl < sl) { + return nil; + } + first = *(const char *)(s); + stop = (const char *)(in) + (inl - sl); + for (p = (const char *)(in); p <= stop; p++) { + if (*p == first && __builtin_memcmp(p + 1, (const char *)(s) + 1, sl - 1) == 0) { + return (const void *)(p); + } + } + return nil; +} + +#endif + intgo Compare(struct __go_open_array, struct __go_open_array) __asm__(GOSYM_PREFIX "internal_bytealg.Compare") __attribute__((no_split_stack)); diff --git a/libgo/go/internal/bytealg/indexbyte_generic.go b/libgo/go/internal/bytealg/indexbyte_generic.go index 890cd42..6e59fd1 100644 --- a/libgo/go/internal/bytealg/indexbyte_generic.go +++ b/libgo/go/internal/bytealg/indexbyte_generic.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +ignore_for_gccgo +// +build ignore_for_gccgo // +build !386,!amd64,!amd64p32,!s390x,!arm,!arm64,!ppc64,!ppc64le,!mips,!mipsle,!mips64,!mips64le,!wasm package bytealg diff --git a/libgo/go/internal/cpu/cpu_arm.go b/libgo/go/internal/cpu/cpu_arm.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_arm.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_arm64.go b/libgo/go/internal/cpu/cpu_arm64.go index 009f2a2..c4d6b81 100644 --- a/libgo/go/internal/cpu/cpu_arm64.go +++ b/libgo/go/internal/cpu/cpu_arm64.go @@ -4,8 +4,6 @@ package cpu -const CacheLineSize = 64 - // arm64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2. // These are initialized by archauxv in runtime/os_linux_arm64.go. // These should not be changed after they are initialized. diff --git a/libgo/go/internal/cpu/cpu_gccgo.c b/libgo/go/internal/cpu/cpu_gccgo.c index 6625ddc..1d5b492 100644 --- a/libgo/go/internal/cpu/cpu_gccgo.c +++ b/libgo/go/internal/cpu/cpu_gccgo.c @@ -52,12 +52,18 @@ struct xgetbv_ret xgetbv(void) #pragma GCC target("xsave") struct xgetbv_ret xgetbv(void) { - long long r; struct xgetbv_ret ret; - r = _xgetbv(0); - ret.eax = r & 0xffffffff; - ret.edx = r >> 32; + // At some point, use call to _xgetbv() instead: + // + // long long r = _xgetbv(0); + // ret.eax = r & 0xffffffff; + // ret.edx = r >> 32; + // + unsigned int __eax, __edx, __xcr_no = 0; + __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no)); + ret.eax = __eax; + ret.edx = __edx; return ret; } diff --git a/libgo/go/internal/cpu/cpu_mips.go b/libgo/go/internal/cpu/cpu_mips.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mips.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_mips64.go b/libgo/go/internal/cpu/cpu_mips64.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mips64.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_mips64le.go b/libgo/go/internal/cpu/cpu_mips64le.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mips64le.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_mipsle.go b/libgo/go/internal/cpu/cpu_mipsle.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mipsle.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_ppc64x.go b/libgo/go/internal/cpu/cpu_ppc64x.go index d3f02ef..5c4bed7 100644 --- a/libgo/go/internal/cpu/cpu_ppc64x.go +++ b/libgo/go/internal/cpu/cpu_ppc64x.go @@ -6,8 +6,6 @@ package cpu -const CacheLineSize = 128 - // ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2. // These are initialized by archauxv in runtime/os_linux_ppc64x.go. // These should not be changed after they are initialized. diff --git a/libgo/go/internal/cpu/cpu_s390x.go b/libgo/go/internal/cpu/cpu_s390x.go index 9dedb4c..43fa4ad 100644 --- a/libgo/go/internal/cpu/cpu_s390x.go +++ b/libgo/go/internal/cpu/cpu_s390x.go @@ -4,8 +4,6 @@ package cpu -const CacheLineSize = 256 - // bitIsSet reports whether the bit at index is set. The bit index // is in big endian order, so bit index 0 is the leftmost bit. func bitIsSet(bits []uint64, index uint) bool { diff --git a/libgo/go/internal/cpu/cpu_x86.go b/libgo/go/internal/cpu/cpu_x86.go index 7d9d3aa..5f15965 100644 --- a/libgo/go/internal/cpu/cpu_x86.go +++ b/libgo/go/internal/cpu/cpu_x86.go @@ -6,8 +6,6 @@ package cpu -const CacheLineSize = 64 - // cpuid is implemented in cpu_x86.s. func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) diff --git a/libgo/go/internal/poll/splice_linux.go b/libgo/go/internal/poll/splice_linux.go index aa237e5..4265b42 100644 --- a/libgo/go/internal/poll/splice_linux.go +++ b/libgo/go/internal/poll/splice_linux.go @@ -162,10 +162,15 @@ func newTempPipe() (prfd, pwfd int, sc string, err error) { defer atomic.StorePointer(&disableSplice, unsafe.Pointer(p)) // F_GETPIPE_SZ was added in 2.6.35, which does not have the -EAGAIN bug. - if _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 { + if syscall.F_GETPIPE_SZ == 0 { *p = true destroyTempPipe(fds[0], fds[1]) - return -1, -1, "fcntl", errno + return -1, -1, "fcntl", syscall.EINVAL + } + if _, errno := fcntl(uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 { + *p = true + destroyTempPipe(fds[0], fds[1]) + return -1, -1, "fcntl", syscall.Errno(errno) } } diff --git a/libgo/go/internal/cpu/cpu_wasm.go b/libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go index 1107a7a..911b608 100644 --- a/libgo/go/internal/cpu/cpu_wasm.go +++ b/libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package cpu +package unix -const CacheLineSize = 64 +// Linux getrandom system call number. +// See GetRandom in getrandom_linux.go. +const randomTrap uintptr = 0x40000000 + 318 diff --git a/libgo/go/net/splice_test.go b/libgo/go/net/splice_test.go index 44a5c00..40ed19b 100644 --- a/libgo/go/net/splice_test.go +++ b/libgo/go/net/splice_test.go @@ -11,7 +11,9 @@ import ( "fmt" "io" "io/ioutil" + "os" "sync" + "syscall" "testing" ) @@ -225,6 +227,10 @@ func testSpliceReaderAtEOF(t *testing.T) { serverUp.Close() _, err, handled := splice(serverDown.(*TCPConn).fd, serverUp) if !handled { + if serr, ok := err.(*os.SyscallError); ok && serr.Syscall == "pipe2" && serr.Err == syscall.ENOSYS { + t.Skip("pipe2 not supported") + } + t.Errorf("closed connection: got err = %v, handled = %t, want handled = true", err, handled) } lr := &io.LimitedReader{ diff --git a/libgo/go/os/executable_solaris.go b/libgo/go/os/executable_solaris.go index b145980..a2ad62a 100644 --- a/libgo/go/os/executable_solaris.go +++ b/libgo/go/os/executable_solaris.go @@ -4,14 +4,18 @@ package os -import "syscall" +import ( + "syscall" + _ "unsafe" // for go:linkname +) -var executablePath string // set by sysauxv in ../runtime/os3_solaris.go +// solarisExecutablePath is defined in the runtime package. +func solarisExecutablePath() string var initCwd, initCwdErr = Getwd() func executable() (string, error) { - path := executablePath + path := solarisExecutablePath() if len(path) == 0 { path, err := syscall.Getexecname() if err != nil { diff --git a/libgo/go/runtime/lfstack_32bit.go b/libgo/go/runtime/lfstack_32bit.go index 1288c1a..f50c508 100644 --- a/libgo/go/runtime/lfstack_32bit.go +++ b/libgo/go/runtime/lfstack_32bit.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc +// +build 386 amd64p32 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc package runtime diff --git a/libgo/go/runtime/os3_solaris.go b/libgo/go/runtime/os3_solaris.go new file mode 100644 index 0000000..c19f797 --- /dev/null +++ b/libgo/go/runtime/os3_solaris.go @@ -0,0 +1,54 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +import ( + "runtime/internal/sys" + "unsafe" +) + +var executablePath string + +func sysargs(argc int32, argv **byte) { + n := argc + 1 + + // skip over argv, envp to get to auxv + for argv_index(argv, n) != nil { + n++ + } + + // skip NULL separator + n++ + + // now argv+n is auxv + auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) + sysauxv(auxv[:]) +} + +const ( + _AT_NULL = 0 // Terminates the vector + _AT_PAGESZ = 6 // Page size in bytes + _AT_SUN_EXECNAME = 2014 // exec() path name +) + +func sysauxv(auxv []uintptr) { + for i := 0; auxv[i] != _AT_NULL; i += 2 { + tag, val := auxv[i], auxv[i+1] + switch tag { + case _AT_PAGESZ: + physPageSize = val + case _AT_SUN_EXECNAME: + executablePath = gostringnocopy((*byte)(unsafe.Pointer(val))) + } + } +} + +//go:linkname solarisExecutablePath os.solarisExecutablePath + +// solarisExecutablePath is called from the os package to fetch the +// saved executable path. +func solarisExecutablePath() string { + return executablePath +} diff --git a/libgo/go/runtime/os_linux_arm.go b/libgo/go/runtime/os_linux_arm.go index 42c2839..4b86455 100644 --- a/libgo/go/runtime/os_linux_arm.go +++ b/libgo/go/runtime/os_linux_arm.go @@ -19,25 +19,6 @@ var armArch uint8 = 6 // we default to ARMv6 var hwcap uint32 // set by archauxv var hardDiv bool // set if a hardware divider is available -func checkgoarm() { - // On Android, /proc/self/auxv might be unreadable and hwcap won't - // reflect the CPU capabilities. Assume that every Android arm device - // has the necessary floating point hardware available. - if GOOS == "android" { - return - } - if goarm > 5 && hwcap&_HWCAP_VFP == 0 { - print("runtime: this CPU has no floating point hardware, so it cannot run\n") - print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n") - exit(1) - } - if goarm > 6 && hwcap&_HWCAP_VFPv3 == 0 { - print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n") - print("this GOARM=", goarm, " binary. Recompile using GOARM=5 or GOARM=6.\n") - exit(1) - } -} - func archauxv(tag, val uintptr) { switch tag { case _AT_RANDOM: diff --git a/libgo/go/runtime/stubs3.go b/libgo/go/runtime/stubs3.go index 5c0786e..1af693b 100644 --- a/libgo/go/runtime/stubs3.go +++ b/libgo/go/runtime/stubs3.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // +build !plan9 -// +build !solaris // +build !windows // +build !nacl // +build !freebsd diff --git a/libgo/go/syscall/syscall_linux_test.go b/libgo/go/syscall/syscall_linux_test.go index 99de6eb..77a822d 100644 --- a/libgo/go/syscall/syscall_linux_test.go +++ b/libgo/go/syscall/syscall_linux_test.go @@ -302,6 +302,10 @@ func TestSyscallNoError(t *testing.T) { t.Skip("skipping root only test") } + if syscall.Sys_GETEUID == 0 { + t.Skip("skipping because there is no geteuid system call") + } + // Copy the test binary to a location that a non-root user can read/execute // after we drop privileges tempDir, err := ioutil.TempDir("", "TestSyscallNoError") diff --git a/libgo/goarch.sh b/libgo/goarch.sh index f5c0a34..f7aef9d 100755 --- a/libgo/goarch.sh +++ b/libgo/goarch.sh @@ -57,10 +57,15 @@ case $goarch in defaultphyspagesize=8192 pcquantum=4 ;; - amd64 | amd64p32) + amd64) family=AMD64 hugepagesize="1 << 21" ;; + amd64p32) + family=AMD64 + hugepagesize="1 << 21" + ptrsize=4 + ;; arm | armbe) family=ARM cachelinesize=32 diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 48bc71d..b7b9fdc 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -73,6 +73,11 @@ if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT} fi +# The internal/poll package requires F_GETPIPE_SZ to be defined. +if ! grep '^const F_GETPIPE_SZ' ${OUT} >/dev/null 2>&1; then + echo "const F_GETPIPE_SZ = 0" >> ${OUT} +fi + # AIX 7.1 is a 64 bits value for _FCLOEXEC (referenced by O_CLOEXEC) # which leads to a constant overflow when using O_CLOEXEC in some # go code. Issue wan not present in 6.1 (no O_CLOEXEC) and is no @@ -133,6 +138,12 @@ if ! grep '^const SYS_GETDENTS64 ' ${OUT} >/dev/null 2>&1; then echo "const SYS_GETDENTS64 = 0" >> ${OUT} fi +# The syscall package wants the geteuid system call number. It isn't +# defined on Alpha, which only provides the getresuid system call. +if ! grep '^const SYS_GETEUID ' ${OUT} >/dev/null 2>&1; then + echo "const SYS_GETEUID = 0" >> ${OUT} +fi + # Stat constants. grep '^const _S_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} diff --git a/libgo/runtime/aeshash.c b/libgo/runtime/aeshash.c index 7f29baa..00658d7 100644 --- a/libgo/runtime/aeshash.c +++ b/libgo/runtime/aeshash.c @@ -573,13 +573,412 @@ uintptr aeshashbody(void* p, uintptr seed, uintptr size, Slice aeskeysched) { #endif // !defined(__x86_64__) -#else // !defined(__i386__) && !defined(__x86_64__) || !defined(HAVE_AS_X86_AES) +#elif defined(__aarch64__) + +// Undefine some identifiers that we pick up from the Go runtime package that +// are used in arm_neon.h. + +#undef t1 +#undef tx +#undef t2 +#undef t3 +#undef t4 +#undef t5 + +#include <arm_neon.h> + +// Force appropriate CPU level. We won't call here unless the CPU +// supports it. + +#pragma GCC target("+crypto") + +// The arm64 version of aeshashbody. + +uintptr aeshashbody(void* p, uintptr seed, uintptr size, Slice aeskeysched) { + uint8x16_t *pseed; + uint32x4_t vinit32; + uint8x16_t vinit; + uint8x16_t vseed, vseed2, vseed3, vseed4; + uint8x16_t vseed5, vseed6, vseed7, vseed8; + uint8x16_t vval, vval2, vval3, vval4; + uint8x16_t vval5, vval6, vval7, vval8; + uint8x16_t vvalLoop, vvalLoop2, vvalLoop3, vvalLoop4; + uint8x16_t vvalLoop5, vvalLoop6, vvalLoop7, vvalLoop8; + uint8x16x2_t avval2; + uint8x16x3_t avseed3; + + pseed = (uint8x16_t*)(aeskeysched.__values); + + // Combined hash seed and length. + vinit32 = vdupq_n_u32(0); + vinit32[0] = (uint32)seed; + vinit32[1] = (uint32)size; + vinit = vreinterpretq_u8_u32(vinit32); + + // Mix in per-process seed. + vseed = vaeseq_u8(*pseed, vinit); + ++pseed; + // Scramble seed. + vseed = vaesmcq_u8(vseed); + + if (size <= 16) { + if (size == 0) { + // Return 64 bits of scrambled input seed. + return vreinterpretq_u64_u8(vseed)[0]; + } else if (size < 16) { + vval = vreinterpretq_u8_u32(vdupq_n_u32(0)); + if ((size & 8) != 0) { + vval = vreinterpretq_u8_u64(vld1q_lane_u64((uint64_t*)(p), vreinterpretq_u64_u8(vval), 0)); + p = (void*)((uint64_t*)(p) + 1); + } + if ((size & 4) != 0) { + vval = vreinterpretq_u8_u32(vld1q_lane_u32((uint32_t*)(p), vreinterpretq_u32_u8(vval), 2)); + p = (void*)((uint32_t*)(p) + 1); + } + if ((size & 2) != 0) { + vval = vreinterpretq_u8_u16(vld1q_lane_u16((uint16_t*)(p), vreinterpretq_u16_u8(vval), 6)); + p = (void*)((uint16_t*)(p) + 1); + } + if ((size & 1) != 0) { + vval = vld1q_lane_u8((uint8*)(p), vval, 14); + } + } else { + vval = *(uint8x16_t*)(p); + } + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval = vaeseq_u8(vval, vseed); + return vreinterpretq_u64_u8(vval)[0]; + } else if (size <= 32) { + // Make a second seed. + vseed2 = vaeseq_u8(*pseed, vinit); + vseed2 = vaesmcq_u8(vseed2); + vval = *(uint8x16_t*)(p); + vval2 = *(uint8x16_t*)((char*)(p) + (size - 16)); + + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vseed2); + vval2 = vaesmcq_u8(vval2); + + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vseed2); + vval2 = vaesmcq_u8(vval2); + + vval = vaeseq_u8(vval, vseed); + vval2 = vaeseq_u8(vval2, vseed2); + + vval ^= vval2; + + return vreinterpretq_u64_u8(vval)[0]; + } else if (size <= 64) { + avseed3 = vld1q_u8_x3((uint8*)(pseed)); + vseed2 = avseed3.val[0]; + vseed3 = avseed3.val[1]; + vseed4 = avseed3.val[2]; + + vseed2 = vaeseq_u8(vseed2, vinit); + vseed2 = vaesmcq_u8(vseed2); + vseed3 = vaeseq_u8(vseed3, vinit); + vseed3 = vaesmcq_u8(vseed3); + vseed4 = vaeseq_u8(vseed4, vinit); + vseed4 = vaesmcq_u8(vseed4); + + avval2 = vld1q_u8_x2((uint8*)(p)); + vval = avval2.val[0]; + vval2 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 32)); + vval3 = avval2.val[0]; + vval4 = avval2.val[1]; + + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vseed2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vseed3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vseed4); + vval4 = vaesmcq_u8(vval4); + + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vseed2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vseed3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vseed4); + vval4 = vaesmcq_u8(vval4); + + vval = vaeseq_u8(vval, vseed); + vval2 = vaeseq_u8(vval2, vseed2); + vval3 = vaeseq_u8(vval3, vseed3); + vval4 = vaeseq_u8(vval4, vseed4); + + vval ^= vval3; + vval2 ^= vval4; + vval ^= vval2; + + return vreinterpretq_u64_u8(vval)[0]; + } else if (size <= 128) { + // For some reason vld1q_u8_x4 is missing. + avseed3 = vld1q_u8_x3((uint8*)(pseed)); + vseed2 = avseed3.val[0]; + vseed3 = avseed3.val[1]; + vseed4 = avseed3.val[2]; + avseed3 = vld1q_u8_x3((uint8*)(pseed + 3)); + vseed5 = avseed3.val[0]; + vseed6 = avseed3.val[1]; + vseed7 = avseed3.val[2]; + vseed8 = *(pseed + 6); + + vseed2 = vaeseq_u8(vseed2, vinit); + vseed2 = vaesmcq_u8(vseed2); + vseed3 = vaeseq_u8(vseed3, vinit); + vseed3 = vaesmcq_u8(vseed3); + vseed4 = vaeseq_u8(vseed4, vinit); + vseed4 = vaesmcq_u8(vseed4); + vseed5 = vaeseq_u8(vseed5, vinit); + vseed5 = vaesmcq_u8(vseed5); + vseed6 = vaeseq_u8(vseed6, vinit); + vseed6 = vaesmcq_u8(vseed6); + vseed7 = vaeseq_u8(vseed7, vinit); + vseed7 = vaesmcq_u8(vseed7); + vseed8 = vaeseq_u8(vseed8, vinit); + vseed8 = vaesmcq_u8(vseed8); + + avval2 = vld1q_u8_x2((uint8*)(p)); + vval = avval2.val[0]; + vval2 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + 32); + vval3 = avval2.val[0]; + vval4 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 64)); + vval5 = avval2.val[0]; + vval6 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 32)); + vval7 = avval2.val[0]; + vval8 = avval2.val[1]; + + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vseed2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vseed3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vseed4); + vval4 = vaesmcq_u8(vval4); + vval5 = vaeseq_u8(vval5, vseed5); + vval5 = vaesmcq_u8(vval5); + vval6 = vaeseq_u8(vval6, vseed6); + vval6 = vaesmcq_u8(vval6); + vval7 = vaeseq_u8(vval7, vseed7); + vval7 = vaesmcq_u8(vval7); + vval8 = vaeseq_u8(vval8, vseed8); + vval8 = vaesmcq_u8(vval8); + + vval = vaeseq_u8(vval, vseed); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vseed2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vseed3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vseed4); + vval4 = vaesmcq_u8(vval4); + vval5 = vaeseq_u8(vval5, vseed5); + vval5 = vaesmcq_u8(vval5); + vval6 = vaeseq_u8(vval6, vseed6); + vval6 = vaesmcq_u8(vval6); + vval7 = vaeseq_u8(vval7, vseed7); + vval7 = vaesmcq_u8(vval7); + vval8 = vaeseq_u8(vval8, vseed8); + vval8 = vaesmcq_u8(vval8); + + vval = vaeseq_u8(vval, vseed); + vval2 = vaeseq_u8(vval2, vseed2); + vval3 = vaeseq_u8(vval3, vseed3); + vval4 = vaeseq_u8(vval4, vseed4); + vval5 = vaeseq_u8(vval5, vseed5); + vval6 = vaeseq_u8(vval6, vseed6); + vval7 = vaeseq_u8(vval7, vseed7); + vval8 = vaeseq_u8(vval8, vseed8); + + vval ^= vval5; + vval2 ^= vval6; + vval3 ^= vval7; + vval4 ^= vval8; + vval ^= vval3; + vval2 ^= vval4; + vval ^= vval2; + + return vreinterpretq_u64_u8(vval)[0]; + } else { + // For some reason vld1q_u8_x4 is missing. + avseed3 = vld1q_u8_x3((uint8*)(pseed)); + vseed2 = avseed3.val[0]; + vseed3 = avseed3.val[1]; + vseed4 = avseed3.val[2]; + avseed3 = vld1q_u8_x3((uint8*)(pseed + 3)); + vseed5 = avseed3.val[0]; + vseed6 = avseed3.val[1]; + vseed7 = avseed3.val[2]; + vseed8 = *(pseed + 6); + + vseed2 = vaeseq_u8(vseed2, vinit); + vseed2 = vaesmcq_u8(vseed2); + vseed3 = vaeseq_u8(vseed3, vinit); + vseed3 = vaesmcq_u8(vseed3); + vseed4 = vaeseq_u8(vseed4, vinit); + vseed4 = vaesmcq_u8(vseed4); + vseed5 = vaeseq_u8(vseed5, vinit); + vseed5 = vaesmcq_u8(vseed5); + vseed6 = vaeseq_u8(vseed6, vinit); + vseed6 = vaesmcq_u8(vseed6); + vseed7 = vaeseq_u8(vseed7, vinit); + vseed7 = vaesmcq_u8(vseed7); + vseed8 = vaeseq_u8(vseed8, vinit); + vseed8 = vaesmcq_u8(vseed8); + + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 128)); + vval = avval2.val[0]; + vval2 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 96)); + vval3 = avval2.val[0]; + vval4 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 64)); + vval5 = avval2.val[0]; + vval6 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + (size - 32)); + vval7 = avval2.val[0]; + vval8 = avval2.val[1]; + + vvalLoop = vseed; + vvalLoop2 = vseed2; + vvalLoop3 = vseed3; + vvalLoop4 = vseed4; + vvalLoop5 = vseed5; + vvalLoop6 = vseed6; + vvalLoop7 = vseed7; + vvalLoop8 = vseed8; + + size--; + size >>= 7; + do { + vval = vaeseq_u8(vval, vvalLoop); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vvalLoop2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vvalLoop3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vvalLoop4); + vval4 = vaesmcq_u8(vval4); + vval5 = vaeseq_u8(vval5, vvalLoop5); + vval5 = vaesmcq_u8(vval5); + vval6 = vaeseq_u8(vval6, vvalLoop6); + vval6 = vaesmcq_u8(vval6); + vval7 = vaeseq_u8(vval7, vvalLoop7); + vval7 = vaesmcq_u8(vval7); + vval8 = vaeseq_u8(vval8, vvalLoop8); + vval8 = vaesmcq_u8(vval8); + + avval2 = vld1q_u8_x2((uint8*)(p)); + vvalLoop = avval2.val[0]; + vvalLoop2 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + 32); + vvalLoop3 = avval2.val[0]; + vvalLoop4 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + 64); + vvalLoop5 = avval2.val[0]; + vvalLoop6 = avval2.val[1]; + avval2 = vld1q_u8_x2((uint8*)(p) + 96); + vvalLoop7 = avval2.val[0]; + vvalLoop8 = avval2.val[1]; + + p = (void *)((uint8*)(p) + 128); + + vval = vaeseq_u8(vval, vvalLoop); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vvalLoop2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vvalLoop3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vvalLoop4); + vval4 = vaesmcq_u8(vval4); + vval5 = vaeseq_u8(vval5, vvalLoop5); + vval5 = vaesmcq_u8(vval5); + vval6 = vaeseq_u8(vval6, vvalLoop6); + vval6 = vaesmcq_u8(vval6); + vval7 = vaeseq_u8(vval7, vvalLoop7); + vval7 = vaesmcq_u8(vval7); + vval8 = vaeseq_u8(vval8, vvalLoop8); + vval8 = vaesmcq_u8(vval8); + } while (--size > 0); + + vval = vaeseq_u8(vval, vvalLoop); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vvalLoop2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vvalLoop3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vvalLoop4); + vval4 = vaesmcq_u8(vval4); + vval5 = vaeseq_u8(vval5, vvalLoop5); + vval5 = vaesmcq_u8(vval5); + vval6 = vaeseq_u8(vval6, vvalLoop6); + vval6 = vaesmcq_u8(vval6); + vval7 = vaeseq_u8(vval7, vvalLoop7); + vval7 = vaesmcq_u8(vval7); + vval8 = vaeseq_u8(vval8, vvalLoop8); + vval8 = vaesmcq_u8(vval8); + + + vval = vaeseq_u8(vval, vvalLoop); + vval = vaesmcq_u8(vval); + vval2 = vaeseq_u8(vval2, vvalLoop2); + vval2 = vaesmcq_u8(vval2); + vval3 = vaeseq_u8(vval3, vvalLoop3); + vval3 = vaesmcq_u8(vval3); + vval4 = vaeseq_u8(vval4, vvalLoop4); + vval4 = vaesmcq_u8(vval4); + vval5 = vaeseq_u8(vval5, vvalLoop5); + vval5 = vaesmcq_u8(vval5); + vval6 = vaeseq_u8(vval6, vvalLoop6); + vval6 = vaesmcq_u8(vval6); + vval7 = vaeseq_u8(vval7, vvalLoop7); + vval7 = vaesmcq_u8(vval7); + vval8 = vaeseq_u8(vval8, vvalLoop8); + vval8 = vaesmcq_u8(vval8); + + vval = vaeseq_u8(vval, vvalLoop); + vval2 = vaeseq_u8(vval2, vvalLoop2); + vval3 = vaeseq_u8(vval3, vvalLoop3); + vval4 = vaeseq_u8(vval4, vvalLoop4); + vval5 = vaeseq_u8(vval5, vvalLoop5); + vval6 = vaeseq_u8(vval6, vvalLoop6); + vval7 = vaeseq_u8(vval7, vvalLoop7); + vval8 = vaeseq_u8(vval8, vvalLoop8); + + vval ^= vval5; + vval2 ^= vval6; + vval3 ^= vval7; + vval4 ^= vval8; + vval ^= vval3; + vval2 ^= vval4; + vval ^= vval2; + + return vreinterpretq_u64_u8(vval)[0]; + } +} + +#else // (!defined(__i386__) && !defined(__x86_64__) || !defined(HAVE_AS_X86_AES)) && !defined(__aarch64__) uintptr aeshashbody(void* p __attribute__((unused)), uintptr seed __attribute__((unused)), uintptr size __attribute__((unused)), Slice aeskeysched __attribute__((unused))) { - // We should never get here on a non-x86 system. + // We should never get here on a non-x86, non-arm64 system. runtime_throw("impossible call to aeshashbody"); } |