mirror of
https://github.com/fumiama/blake2b-simd.git
synced 2026-06-05 18:20:29 +08:00
With this change, following happens.
```
if sse {
compressSSE()
return
}
compressGeneric()
```
compressGeneric is used as a fallback when SSE is not detected.
30 lines
926 B
Go
30 lines
926 B
Go
// +build 386,!gccgo amd64,!gccgo
|
|
|
|
// Copyright 2016 Frank Wessels <fwessels@xs4all.nl>
|
|
//
|
|
// 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 blake2b
|
|
|
|
func cpuid(op uint32) (eax, ebx, ecx, edx uint32)
|
|
|
|
// True when SIMD instructions are available.
|
|
var sse = haveSSE()
|
|
|
|
// haveSSE returns true if we have streaming SIMD instructions.
|
|
func haveSSE() bool {
|
|
_, _, _, d := cpuid(1)
|
|
return (d & (1 << 25)) != 0
|
|
}
|