vendor: Update github.com/minio/sha256-simd, CPU detection (Linux)

This commit is contained in:
Jakob Borg 2016-12-20 09:20:28 +01:00
parent 2f770f8bfb
commit 21eb098dd2
8 changed files with 1272 additions and 9 deletions

View File

@ -1,4 +1,24 @@
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
// The MIT License (MIT)
//
// Copyright (c) 2015 Klaus Post
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// +build 386,!gccgo

View File

@ -1,4 +1,24 @@
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
// The MIT License (MIT)
//
// Copyright (c) 2015 Klaus Post
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// +build amd64,!gccgo

View File

@ -28,6 +28,5 @@ func xgetbv(index uint32) (eax, edx uint32) {
}
func haveArmSha() bool {
// TODO: Implement feature detection for ARM
return true
return false
}

View File

@ -0,0 +1,49 @@
// +build arm64,linux
// Minio Cloud Storage, (C) 2016 Minio, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package sha256
import (
"bytes"
"io/ioutil"
)
func cpuid(op uint32) (eax, ebx, ecx, edx uint32) {
return 0, 0, 0, 0
}
func cpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) {
return 0, 0, 0, 0
}
func xgetbv(index uint32) (eax, edx uint32) {
return 0, 0
}
// File to check for cpu capabilities.
const procCPUInfo = "/proc/cpuinfo"
// Feature to check for.
const sha256Feature = "sha2"
func haveArmSha() bool {
cpuInfo, err := ioutil.ReadFile(procCPUInfo)
if err != nil {
return false
}
return bytes.Contains(cpuInfo, []byte(sha256Feature))
}

View File

@ -1,3 +1,5 @@
// +build arm64,!linux
// Minio Cloud Storage, (C) 2016 Minio, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -27,7 +29,7 @@ func xgetbv(index uint32) (eax, edx uint32) {
return 0, 0
}
// Check for sha2 instruction flag.
func haveArmSha() bool {
// TODO: Implement feature detection for ARM
return true
return false
}

View File

@ -89,7 +89,8 @@ func New() hash.Hash {
d.Reset()
return d
}
// default back to the standard golang implementation
// Fallback to the standard golang implementation
// if no features were found.
return sha256.New()
}

1172
vendor/github.com/minio/sha256-simd/sha256_test.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

4
vendor/manifest vendored
View File

@ -205,8 +205,8 @@
{
"importpath": "github.com/minio/sha256-simd",
"repository": "https://github.com/minio/sha256-simd",
"vcs": "",
"revision": "672e7bc9f3482375df73741cf57a157fe187ec26",
"vcs": "git",
"revision": "e82e73b775766b9011503e80e6772fc32b9afc5b",
"branch": "master"
},
{