1
0
mirror of https://github.com/golang/go synced 2024-10-02 06:28:33 -06:00
go/src/runtime/os_linux_s390x.go
Michael Munday f1ad4863aa runtime: get s390x vector facility availability from AT_HWCAP
This is a more robust method for obtaining the availability of vx.
Since this variable may be checked frequently I've also now
padded it so that it will be in its own cache line.

I've kept the other check (in hash/crc32) the same for now until
I can figure out the best way to update it.

Updates #15403.

Change-Id: I74eed651afc6f6a9c5fa3b88fa6a2b0c9ecf5875
Reviewed-on: https://go-review.googlesource.com/31149
Reviewed-by: Austin Clements <austin@google.com>
2016-10-19 21:50:13 +00:00

33 lines
762 B
Go

// Copyright 2016 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"
)
const (
// bit masks taken from bits/hwcap.h
_HWCAP_S390_VX = 2048 // vector facility
)
// facilities is padded to avoid false sharing.
type facilities struct {
_ [sys.CacheLineSize]byte
hasVX bool // vector facility
_ [sys.CacheLineSize]byte
}
// cpu indicates the availability of s390x facilities that can be used in
// Go assembly but are optional on models supported by Go.
var cpu facilities
func archauxv(tag, val uintptr) {
switch tag {
case _AT_HWCAP: // CPU capability bit flags
cpu.hasVX = val&_HWCAP_S390_VX != 0
}
}