diff options
author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/minio/sha256-simd/cpuid_other.go | |
parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip |
Make Nix builds work
Diffstat (limited to 'vendor/github.com/minio/sha256-simd/cpuid_other.go')
-rw-r--r-- | vendor/github.com/minio/sha256-simd/cpuid_other.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/vendor/github.com/minio/sha256-simd/cpuid_other.go b/vendor/github.com/minio/sha256-simd/cpuid_other.go new file mode 100644 index 0000000..97af6a1 --- /dev/null +++ b/vendor/github.com/minio/sha256-simd/cpuid_other.go | |||
@@ -0,0 +1,50 @@ | |||
1 | // Minio Cloud Storage, (C) 2021 Minio, Inc. | ||
2 | // | ||
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | // you may not use this file except in compliance with the License. | ||
5 | // You may obtain a copy of the License at | ||
6 | // | ||
7 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | // | ||
9 | // Unless required by applicable law or agreed to in writing, software | ||
10 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | // See the License for the specific language governing permissions and | ||
13 | // limitations under the License. | ||
14 | // | ||
15 | |||
16 | package sha256 | ||
17 | |||
18 | import ( | ||
19 | "bytes" | ||
20 | "io/ioutil" | ||
21 | "runtime" | ||
22 | |||
23 | "github.com/klauspost/cpuid/v2" | ||
24 | ) | ||
25 | |||
26 | var ( | ||
27 | hasIntelSha = runtime.GOARCH == "amd64" && cpuid.CPU.Supports(cpuid.SHA, cpuid.SSSE3, cpuid.SSE4) | ||
28 | hasAvx512 = cpuid.CPU.Supports(cpuid.AVX512F, cpuid.AVX512DQ, cpuid.AVX512BW, cpuid.AVX512VL) | ||
29 | ) | ||
30 | |||
31 | func hasArmSha2() bool { | ||
32 | if cpuid.CPU.Has(cpuid.SHA2) { | ||
33 | return true | ||
34 | } | ||
35 | if runtime.GOARCH != "arm64" || runtime.GOOS != "linux" { | ||
36 | return false | ||
37 | } | ||
38 | |||
39 | // Fall back to hacky cpuinfo parsing... | ||
40 | const procCPUInfo = "/proc/cpuinfo" | ||
41 | |||
42 | // Feature to check for. | ||
43 | const sha256Feature = "sha2" | ||
44 | |||
45 | cpuInfo, err := ioutil.ReadFile(procCPUInfo) | ||
46 | if err != nil { | ||
47 | return false | ||
48 | } | ||
49 | return bytes.Contains(cpuInfo, []byte(sha256Feature)) | ||
50 | } | ||