github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/klauspost/crc32/crc32_amd64p32.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build !appengine,!gccgo 6 7 package crc32 8 9 // This file contains the code to call the SSE 4.2 version of the Castagnoli 10 // CRC. 11 12 // haveSSE42 is defined in crc_amd64p32.s and uses CPUID to test for SSE 4.2 13 // support. 14 func haveSSE42() bool 15 16 // castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32 17 // instruction. 18 //go:noescape 19 func castagnoliSSE42(crc uint32, p []byte) uint32 20 21 var sse42 = haveSSE42() 22 23 func updateCastagnoli(crc uint32, p []byte) uint32 { 24 if sse42 { 25 return castagnoliSSE42(crc, p) 26 } 27 return update(crc, castagnoliTable, p) 28 } 29 30 func updateIEEE(crc uint32, p []byte) uint32 { 31 // only use slicing-by-8 when input is >= 4KB 32 if len(p) >= 4096 { 33 ieeeTable8Once.Do(func() { 34 ieeeTable8 = makeTable8(IEEE) 35 }) 36 return updateSlicingBy8(crc, ieeeTable8, p) 37 } 38 39 return update(crc, IEEETable, p) 40 }