crc32_amd64x.go 702 B

12345678910111213141516171819202122232425262728
  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. // +build amd64 amd64p32
  5. package crc32
  6. // This file contains the code to call the SSE 4.2 version of the Castagnoli
  7. // CRC.
  8. // haveSSE42 is defined in crc_amd64.s and uses CPUID to test for SSE 4.2
  9. // support.
  10. func haveSSE42() bool
  11. // castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32
  12. // instruction.
  13. func castagnoliSSE42(crc uint32, p []byte) uint32
  14. var sse42 = haveSSE42()
  15. func updateCastagnoli(crc uint32, p []byte) uint32 {
  16. if sse42 {
  17. return castagnoliSSE42(crc, p)
  18. }
  19. return update(crc, castagnoliTable, p)
  20. }