Commit cd0e79d9 authored by Martin Möhrmann's avatar Martin Möhrmann

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 099498db
......@@ -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[:]
......
......@@ -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[:]
......
......@@ -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")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment