From 6ee27daac1d9c34935ef5606f2a724162198b4f2 Mon Sep 17 00:00:00 2001 From: Andreas Auernhammer Date: Mon, 26 Dec 2016 02:03:08 +0100 Subject: [PATCH] fix blake2b tests on non-amd64 machines (#3496) Fix the TestHashes Test for non-amd64 machines --- vendor/golang.org/x/crypto/blake2b/blake2b.go | 6 ++++++ .../x/crypto/blake2b/blake2bAVX2_amd64.go | 14 ++++++++------ .../x/crypto/blake2b/blake2bAVX2_amd64.s | 8 ++++---- .../golang.org/x/crypto/blake2b/blake2b_amd64.go | 8 ++++---- vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s | 4 ++-- vendor/golang.org/x/crypto/blake2b/blake2b_ref.go | 3 --- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/vendor/golang.org/x/crypto/blake2b/blake2b.go b/vendor/golang.org/x/crypto/blake2b/blake2b.go index b736632f9..fa9e48e31 100644 --- a/vendor/golang.org/x/crypto/blake2b/blake2b.go +++ b/vendor/golang.org/x/crypto/blake2b/blake2b.go @@ -23,6 +23,12 @@ const ( Size256 = 32 ) +var ( + useAVX2 bool + useAVX bool + useSSE4 bool +) + var errKeySize = errors.New("blake2b: invalid key size") var iv = [8]uint64{ diff --git a/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go b/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go index 422ba849c..8c41cf6c7 100644 --- a/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go +++ b/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go @@ -6,18 +6,20 @@ package blake2b -var useAVX2 = supportAVX2() -var useAVX = supportAVX() -var useSSE4 = supportSSE4() +func init() { + useAVX2 = supportsAVX2() + useAVX = supportsAVX() + useSSE4 = supportsSSE4() +} //go:noescape -func supportSSE4() bool +func supportsSSE4() bool //go:noescape -func supportAVX() bool +func supportsAVX() bool //go:noescape -func supportAVX2() bool +func supportsAVX2() bool //go:noescape func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) diff --git a/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s b/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s index 86bc182a5..96a51d524 100644 --- a/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s +++ b/vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s @@ -489,14 +489,14 @@ noinc: MOVQ BP, SP RET -// func supportAVX2() bool -TEXT ·supportAVX2(SB), 4, $0-1 +// func supportsAVX2() bool +TEXT ·supportsAVX2(SB), 4, $0-1 MOVQ runtime·support_avx2(SB), AX MOVB AX, ret+0(FP) RET -// func supportAVX() bool -TEXT ·supportAVX(SB), 4, $0-1 +// func supportsAVX() bool +TEXT ·supportsAVX(SB), 4, $0-1 MOVQ runtime·support_avx(SB), AX MOVB AX, ret+0(FP) RET diff --git a/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go b/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go index c9a22fd7d..2ab7c30fc 100644 --- a/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go +++ b/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go @@ -6,12 +6,12 @@ package blake2b -var useAVX2 = false -var useAVX = false -var useSSE4 = supportSSE4() +func init() { + useSSE4 = supportsSSE4() +} //go:noescape -func supportSSE4() bool +func supportsSSE4() bool //go:noescape func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) diff --git a/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s b/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s index 04e45beb5..64530740b 100644 --- a/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s +++ b/vendor/golang.org/x/crypto/blake2b/blake2b_amd64.s @@ -280,8 +280,8 @@ noinc: MOVQ BP, SP RET -// func supportSSE4() bool -TEXT ·supportSSE4(SB), 4, $0-1 +// func supportsSSE4() bool +TEXT ·supportsSSE4(SB), 4, $0-1 MOVL $1, AX CPUID SHRL $19, CX // Bit 19 indicates SSE4 support diff --git a/vendor/golang.org/x/crypto/blake2b/blake2b_ref.go b/vendor/golang.org/x/crypto/blake2b/blake2b_ref.go index 2c3c68b0d..da156a1ba 100644 --- a/vendor/golang.org/x/crypto/blake2b/blake2b_ref.go +++ b/vendor/golang.org/x/crypto/blake2b/blake2b_ref.go @@ -6,9 +6,6 @@ package blake2b -var useAVX2 = false -var useSSE4 = false - func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) { hashBlocksGeneric(h, c, flag, blocks) }