1
0
mirror of https://github.com/golang/go synced 2024-11-23 17:50:06 -07:00

all: use internal/cpu feature variables directly

Avoid using package specific variables when there is a one to one
correspondance to cpu feature support exported by internal/cpu.

This makes it clearer which cpu feature is referenced.
Another advantage is that internal/cpu variables are padded to avoid
false sharing and memory and cache usage is shared by multiple packages.

Change-Id: If18fb448a95207cfa6a3376f3b2ddc4b230dd138
Reviewed-on: https://go-review.googlesource.com/126596
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Martin Möhrmann 2018-07-28 09:08:09 +02:00
parent 099498db0e
commit cd0e79d9f1
3 changed files with 8 additions and 14 deletions

View File

@ -13,13 +13,11 @@ var k = []uint32{
0xCA62C1D6,
}
var hasSHA1 = cpu.ARM64.HasSHA1
//go:noescape
func sha1block(h []uint32, p []byte, k []uint32)
func block(dig *digest, p []byte) {
if !hasSHA1 {
if !cpu.ARM64.HasSHA1 {
blockGeneric(dig, p)
} else {
h := dig.h[:]

View File

@ -8,13 +8,11 @@ import "internal/cpu"
var k = _K
var hasSHA2 = cpu.ARM64.HasSHA2
//go:noescape
func sha256block(h []uint32, p []byte, k []uint32)
func block(dig *digest, p []byte) {
if !hasSHA2 {
if !cpu.ARM64.HasSHA2 {
blockGeneric(dig, p)
} else {
h := dig.h[:]

View File

@ -13,20 +13,18 @@ import "internal/cpu"
func castagnoliUpdate(crc uint32, p []byte) uint32
func ieeeUpdate(crc uint32, p []byte) uint32
var hasCRC32 = cpu.ARM64.HasCRC32
func archAvailableCastagnoli() bool {
return hasCRC32
return cpu.ARM64.HasCRC32
}
func archInitCastagnoli() {
if !hasCRC32 {
if !cpu.ARM64.HasCRC32 {
panic("arch-specific crc32 instruction for Catagnoli not available")
}
}
func archUpdateCastagnoli(crc uint32, p []byte) uint32 {
if !hasCRC32 {
if !cpu.ARM64.HasCRC32 {
panic("arch-specific crc32 instruction for Castagnoli not available")
}
@ -34,17 +32,17 @@ func archUpdateCastagnoli(crc uint32, p []byte) uint32 {
}
func archAvailableIEEE() bool {
return hasCRC32
return cpu.ARM64.HasCRC32
}
func archInitIEEE() {
if !hasCRC32 {
if !cpu.ARM64.HasCRC32 {
panic("arch-specific crc32 instruction for IEEE not available")
}
}
func archUpdateIEEE(crc uint32, p []byte) uint32 {
if !hasCRC32 {
if !cpu.ARM64.HasCRC32 {
panic("arch-specific crc32 instruction for IEEE not available")
}