• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2017 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// ARM64-specific hardware-assisted CRC32 algorithms. See crc32.go for a
6// description of the interface that each architecture-specific file
7// implements.
8
9package crc32
10
11import "internal/cpu"
12
13func castagnoliUpdate(crc uint32, p []byte) uint32
14func ieeeUpdate(crc uint32, p []byte) uint32
15
16func archAvailableCastagnoli() bool {
17	return cpu.ARM64.HasCRC32
18}
19
20func archInitCastagnoli() {
21	if !cpu.ARM64.HasCRC32 {
22		panic("arch-specific crc32 instruction for Castagnoli not available")
23	}
24}
25
26func archUpdateCastagnoli(crc uint32, p []byte) uint32 {
27	if !cpu.ARM64.HasCRC32 {
28		panic("arch-specific crc32 instruction for Castagnoli not available")
29	}
30
31	return ^castagnoliUpdate(^crc, p)
32}
33
34func archAvailableIEEE() bool {
35	return cpu.ARM64.HasCRC32
36}
37
38func archInitIEEE() {
39	if !cpu.ARM64.HasCRC32 {
40		panic("arch-specific crc32 instruction for IEEE not available")
41	}
42}
43
44func archUpdateIEEE(crc uint32, p []byte) uint32 {
45	if !cpu.ARM64.HasCRC32 {
46		panic("arch-specific crc32 instruction for IEEE not available")
47	}
48
49	return ^ieeeUpdate(^crc, p)
50}
51