1
0
mirror of https://github.com/fumiama/blake2b-simd.git synced 2026-06-05 18:20:29 +08:00
Files
blake2b-simd/cpuid.go
Harshavardhana 3a46db1cb4 Detect SSE automatically and enable corresponding optimized code path.
With this change, following happens.

```
if sse {
   compressSSE()
   return
}
compressGeneric()
```

compressGeneric is used as a fallback when SSE is not detected.
2016-06-28 02:51:14 -07:00

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
}