From 3626398d77499f570be2e36a6ad4fc91963a02c5 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 28 May 2019 09:09:44 -0700 Subject: [PATCH] cpu: don't depend on the golang.org/x/sys/unix package for AIX gccgo support can happen in a future CL. Updates golang/go#32102 Change-Id: Ic9e8d7b3e413079d277bdba565551845a2b78121 Reviewed-on: https://go-review.googlesource.com/c/sys/+/179178 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- cpu/asm_aix_ppc64.s | 17 +++++++++++++++++ cpu/cpu_aix_ppc64.go | 10 +++++++--- cpu/syscall_aix_ppc64_gc.go | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 cpu/asm_aix_ppc64.s create mode 100644 cpu/syscall_aix_ppc64_gc.go diff --git a/cpu/asm_aix_ppc64.s b/cpu/asm_aix_ppc64.s new file mode 100644 index 00000000..06f84b85 --- /dev/null +++ b/cpu/asm_aix_ppc64.s @@ -0,0 +1,17 @@ +// Copyright 2018 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go +// + +TEXT ·syscall6(SB),NOSPLIT,$0-88 + JMP syscall·syscall6(SB) + +TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 + JMP syscall·rawSyscall6(SB) diff --git a/cpu/cpu_aix_ppc64.go b/cpu/cpu_aix_ppc64.go index d8c26a04..be602722 100644 --- a/cpu/cpu_aix_ppc64.go +++ b/cpu/cpu_aix_ppc64.go @@ -6,8 +6,6 @@ package cpu -import "golang.org/x/sys/unix" - const cacheLineSize = 128 const ( @@ -18,7 +16,7 @@ const ( ) func init() { - impl := unix.Getsystemcfg(_SC_IMPL) + impl := getsystemcfg(_SC_IMPL) if impl&_IMPL_POWER8 != 0 { PPC64.IsPOWER8 = true } @@ -28,3 +26,9 @@ func init() { Initialized = true } + +func getsystemcfg(label int) (n uint64) { + r0, _ := callgetsystemcfg(label) + n = uint64(r0) + return +} diff --git a/cpu/syscall_aix_ppc64_gc.go b/cpu/syscall_aix_ppc64_gc.go new file mode 100644 index 00000000..15a8b852 --- /dev/null +++ b/cpu/syscall_aix_ppc64_gc.go @@ -0,0 +1,34 @@ +// Copyright 2019 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. + +// Minimal copy of x/sys/unix so the cpu package can make a +// system call on AIX without depending on x/sys/unix. +// (See golang.org/issue/32102) + +// +build aix,ppc64 +// +build !gccgo + +package cpu + +import ( + "syscall" + "unsafe" +) + +//go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o" + +type syscallFunc uintptr + +var libc_getsystemcfg syscallFunc + +type errno = syscall.Errno + +// Implemented in runtime/syscall_aix.go. +func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno) +func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno) + +func callgetsystemcfg(label int) (r1 uintptr, e1 errno) { + r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0) + return +}