fix blake2b tests on non-amd64 machines (#3496)

Fix the TestHashes Test for non-amd64 machines
This commit is contained in:
Andreas Auernhammer 2016-12-26 02:03:08 +01:00 committed by Harshavardhana
parent cdc6c2d578
commit 6ee27daac1
6 changed files with 24 additions and 19 deletions

View File

@ -23,6 +23,12 @@ const (
Size256 = 32 Size256 = 32
) )
var (
useAVX2 bool
useAVX bool
useSSE4 bool
)
var errKeySize = errors.New("blake2b: invalid key size") var errKeySize = errors.New("blake2b: invalid key size")
var iv = [8]uint64{ var iv = [8]uint64{

View File

@ -6,18 +6,20 @@
package blake2b package blake2b
var useAVX2 = supportAVX2() func init() {
var useAVX = supportAVX() useAVX2 = supportsAVX2()
var useSSE4 = supportSSE4() useAVX = supportsAVX()
useSSE4 = supportsSSE4()
}
//go:noescape //go:noescape
func supportSSE4() bool func supportsSSE4() bool
//go:noescape //go:noescape
func supportAVX() bool func supportsAVX() bool
//go:noescape //go:noescape
func supportAVX2() bool func supportsAVX2() bool
//go:noescape //go:noescape
func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)

View File

@ -489,14 +489,14 @@ noinc:
MOVQ BP, SP MOVQ BP, SP
RET RET
// func supportAVX2() bool // func supportsAVX2() bool
TEXT ·supportAVX2(SB), 4, $0-1 TEXT ·supportsAVX2(SB), 4, $0-1
MOVQ runtime·support_avx2(SB), AX MOVQ runtime·support_avx2(SB), AX
MOVB AX, ret+0(FP) MOVB AX, ret+0(FP)
RET RET
// func supportAVX() bool // func supportsAVX() bool
TEXT ·supportAVX(SB), 4, $0-1 TEXT ·supportsAVX(SB), 4, $0-1
MOVQ runtime·support_avx(SB), AX MOVQ runtime·support_avx(SB), AX
MOVB AX, ret+0(FP) MOVB AX, ret+0(FP)
RET RET

View File

@ -6,12 +6,12 @@
package blake2b package blake2b
var useAVX2 = false func init() {
var useAVX = false useSSE4 = supportsSSE4()
var useSSE4 = supportSSE4() }
//go:noescape //go:noescape
func supportSSE4() bool func supportsSSE4() bool
//go:noescape //go:noescape
func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte)

View File

@ -280,8 +280,8 @@ noinc:
MOVQ BP, SP MOVQ BP, SP
RET RET
// func supportSSE4() bool // func supportsSSE4() bool
TEXT ·supportSSE4(SB), 4, $0-1 TEXT ·supportsSSE4(SB), 4, $0-1
MOVL $1, AX MOVL $1, AX
CPUID CPUID
SHRL $19, CX // Bit 19 indicates SSE4 support SHRL $19, CX // Bit 19 indicates SSE4 support

View File

@ -6,9 +6,6 @@
package blake2b package blake2b
var useAVX2 = false
var useSSE4 = false
func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) { func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
hashBlocksGeneric(h, c, flag, blocks) hashBlocksGeneric(h, c, flag, blocks)
} }