mirror of
https://github.com/golang/sys.git
synced 2026-01-29 15:12:09 +03:00
This adds feature detection that works on the s390x running zos. There are some differences with Linux (no hwcap, facilities vector available in-memory). These changes should not affect other platforms. Fixes golang/go#41984. Change-Id: Ieabbfafd07367a346a4d279dde0f00aa3fc4321b Reviewed-on: https://go-review.googlesource.com/c/sys/+/262477 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Martin Möhrmann <moehrmann@google.com> Trust: Martin Möhrmann <moehrmann@google.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
41 lines
890 B
Go
41 lines
890 B
Go
// 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.
|
|
|
|
package cpu
|
|
|
|
const (
|
|
// bit mask values from /usr/include/bits/hwcap.h
|
|
hwcap_ZARCH = 2
|
|
hwcap_STFLE = 4
|
|
hwcap_MSA = 8
|
|
hwcap_LDISP = 16
|
|
hwcap_EIMM = 32
|
|
hwcap_DFP = 64
|
|
hwcap_ETF3EH = 256
|
|
hwcap_VX = 2048
|
|
hwcap_VXE = 8192
|
|
)
|
|
|
|
func initS390Xbase() {
|
|
// test HWCAP bit vector
|
|
has := func(featureMask uint) bool {
|
|
return hwCap&featureMask == featureMask
|
|
}
|
|
|
|
// mandatory
|
|
S390X.HasZARCH = has(hwcap_ZARCH)
|
|
|
|
// optional
|
|
S390X.HasSTFLE = has(hwcap_STFLE)
|
|
S390X.HasLDISP = has(hwcap_LDISP)
|
|
S390X.HasEIMM = has(hwcap_EIMM)
|
|
S390X.HasETF3EH = has(hwcap_ETF3EH)
|
|
S390X.HasDFP = has(hwcap_DFP)
|
|
S390X.HasMSA = has(hwcap_MSA)
|
|
S390X.HasVX = has(hwcap_VX)
|
|
if S390X.HasVX {
|
|
S390X.HasVXE = has(hwcap_VXE)
|
|
}
|
|
}
|