Skip to content

Commit 3626398

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent adf421d commit 3626398

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

cpu/asm_aix_ppc64.s

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build !gccgo
6+
7+
#include "textflag.h"
8+
9+
//
10+
// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go
11+
//
12+
13+
TEXT ·syscall6(SB),NOSPLIT,$0-88
14+
JMP syscall·syscall6(SB)
15+
16+
TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
17+
JMP syscall·rawSyscall6(SB)

cpu/cpu_aix_ppc64.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
package cpu
88

9-
import "golang.org/x/sys/unix"
10-
119
const cacheLineSize = 128
1210

1311
const (
@@ -18,7 +16,7 @@ const (
1816
)
1917

2018
func init() {
21-
impl := unix.Getsystemcfg(_SC_IMPL)
19+
impl := getsystemcfg(_SC_IMPL)
2220
if impl&_IMPL_POWER8 != 0 {
2321
PPC64.IsPOWER8 = true
2422
}
@@ -28,3 +26,9 @@ func init() {
2826

2927
Initialized = true
3028
}
29+
30+
func getsystemcfg(label int) (n uint64) {
31+
r0, _ := callgetsystemcfg(label)
32+
n = uint64(r0)
33+
return
34+
}

cpu/syscall_aix_ppc64_gc.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Minimal copy of x/sys/unix so the cpu package can make a
6+
// system call on AIX without depending on x/sys/unix.
7+
// (See golang.org/issue/32102)
8+
9+
// +build aix,ppc64
10+
// +build !gccgo
11+
12+
package cpu
13+
14+
import (
15+
"syscall"
16+
"unsafe"
17+
)
18+
19+
//go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o"
20+
21+
type syscallFunc uintptr
22+
23+
var libc_getsystemcfg syscallFunc
24+
25+
type errno = syscall.Errno
26+
27+
// Implemented in runtime/syscall_aix.go.
28+
func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno)
29+
func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno)
30+
31+
func callgetsystemcfg(label int) (r1 uintptr, e1 errno) {
32+
r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0)
33+
return
34+
}

0 commit comments

Comments
 (0)