summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/sha256-simd/sha256.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-28 18:30:40 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-28 18:30:40 +0100
commita156188b3eb5cb3da44aa1b7452265f5fa38a607 (patch)
tree7097fa48d56fbabc7c2c8750b1f3bc9321d71c0f /vendor/github.com/minio/sha256-simd/sha256.go
parent[bugfix] Fix emphasis being added to emoji shortcodes with markdown parsing (... (diff)
downloadgotosocial-a156188b3eb5cb3da44aa1b7452265f5fa38a607.tar.xz
[chore] update dependencies, bump to Go 1.19.1 (#826)
* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'vendor/github.com/minio/sha256-simd/sha256.go')
-rw-r--r--vendor/github.com/minio/sha256-simd/sha256.go34
1 files changed, 12 insertions, 22 deletions
diff --git a/vendor/github.com/minio/sha256-simd/sha256.go b/vendor/github.com/minio/sha256-simd/sha256.go
index 4e1f6d2f7..b137ead9f 100644
--- a/vendor/github.com/minio/sha256-simd/sha256.go
+++ b/vendor/github.com/minio/sha256-simd/sha256.go
@@ -21,6 +21,8 @@ import (
"encoding/binary"
"hash"
"runtime"
+
+ "github.com/klauspost/cpuid/v2"
)
// Size - The size of a SHA256 checksum in bytes.
@@ -67,10 +69,6 @@ type blockfuncType int
const (
blockfuncGeneric blockfuncType = iota
- blockfuncAvx512 blockfuncType = iota
- blockfuncAvx2 blockfuncType = iota
- blockfuncAvx blockfuncType = iota
- blockfuncSsse blockfuncType = iota
blockfuncSha blockfuncType = iota
blockfuncArm blockfuncType = iota
)
@@ -78,26 +76,24 @@ const (
var blockfunc blockfuncType
func init() {
- is386bit := runtime.GOARCH == "386"
- isARM := runtime.GOARCH == "arm"
+ blockfunc = blockfuncGeneric
switch {
- case is386bit || isARM:
- blockfunc = blockfuncGeneric
- case sha && ssse3 && sse41:
+ case hasSHAExtensions():
blockfunc = blockfuncSha
- case avx2:
- blockfunc = blockfuncAvx2
- case avx:
- blockfunc = blockfuncAvx
- case ssse3:
- blockfunc = blockfuncSsse
- case armSha:
+ case hasArmSha2():
blockfunc = blockfuncArm
default:
blockfunc = blockfuncGeneric
}
}
+var avx512 = cpuid.CPU.Supports(cpuid.AVX512F, cpuid.AVX512DQ, cpuid.AVX512BW, cpuid.AVX512VL)
+
+// hasSHAExtensions return whether the cpu supports SHA extensions.
+func hasSHAExtensions() bool {
+ return cpuid.CPU.Supports(cpuid.SHA, cpuid.SSSE3, cpuid.SSE4) && runtime.GOARCH == "amd64"
+}
+
// New returns a new hash.Hash computing the SHA256 checksum.
func New() hash.Hash {
if blockfunc != blockfuncGeneric {
@@ -278,12 +274,6 @@ func (d *digest) checkSum() (digest [Size]byte) {
func block(dig *digest, p []byte) {
if blockfunc == blockfuncSha {
blockShaGo(dig, p)
- } else if blockfunc == blockfuncAvx2 {
- blockAvx2Go(dig, p)
- } else if blockfunc == blockfuncAvx {
- blockAvxGo(dig, p)
- } else if blockfunc == blockfuncSsse {
- blockSsseGo(dig, p)
} else if blockfunc == blockfuncArm {
blockArmGo(dig, p)
} else if blockfunc == blockfuncGeneric {