Imports #
"unsafe"
"internal/cpu"
"errors"
"hash"
"internal/byteorder"
"sync"
"sync/atomic"
"internal/byteorder"
"internal/cpu"
"unsafe"
"internal/cpu"
"internal/cpu"
"unsafe"
"internal/cpu"
"errors"
"hash"
"internal/byteorder"
"sync"
"sync/atomic"
"internal/byteorder"
"internal/cpu"
"unsafe"
"internal/cpu"
"internal/cpu"
Castagnoli's polynomial, used in iSCSI. Has better error detection characteristics than IEEE. https://dx.doi.org/10.1109/26.231911
const Castagnoli = 0x82f63b78
IEEE is by far and away the most common CRC-32 polynomial. Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, ...
const IEEE = 0xedb88320
IEEETable is the table for the [IEEE] polynomial.
var IEEETable = *ast.CallExpr
Koopman's polynomial. Also has better error detection characteristics than IEEE. https://dx.doi.org/10.1109/DSN.2002.1028931
const Koopman = 0xeb31d82e
The size of a CRC-32 checksum in bytes.
const Size = 4
var archCastagnoliTable8 *slicing8Table
var archCastagnoliTable8 *slicing8Table
var archIeeeTable8 *slicing8Table
var archIeeeTable8 *slicing8Table
var archIeeeTable8 *slicing8Table
var castagnoliInitOnce = *ast.CallExpr
const castagnoliK1 = 168
const castagnoliK2 = 1344
var castagnoliSSE42TableK1 *sse42Table
var castagnoliSSE42TableK2 *sse42Table
castagnoliTable points to a lazily initialized Table for the Castagnoli polynomial. MakeTable will always return this value when asked to make a Castagnoli table so we can compare against it to find when the caller is using this polynomial.
var castagnoliTable *Table
var castagnoliTable8 *slicing8Table
const crcCast = 2
const crcIEEE = 1
hasVX reports whether the machine has the z/Architecture vector facility installed and enabled.
var hasVX = cpu.S390X.HasVX
var haveCastagnoli atomic.Bool
var ieeeInitOnce = *ast.CallExpr
ieeeTable8 is the slicing8Table for IEEE
var ieeeTable8 *slicing8Table
const magic = "crc\x01"
const marshaledSize = *ast.BinaryExpr
Use slicing-by-8 when payload >= this value.
const slicing8Cutoff = 16
var updateCastagnoli func(crc uint32, p []byte) uint32
var updateIEEE func(crc uint32, p []byte) uint32
const vecAlignMask = 15
const vecMinLen = 16
const vxAlignMask = 15
const vxMinLen = 64
Table is a 256-word table representing the polynomial for efficient processing.
type Table [256]uint32
slicing8Table is array of 8 Tables, used by the slicing-by-8 algorithm.
type slicing8Table [8]Table
type sse42Table [4]Table
digest represents the partial evaluation of a checksum.
type digest struct {
crc uint32
tab *Table
}
func (d *digest) AppendBinary(b []byte) ([]byte, error)
func (d *digest) BlockSize() int
Checksum returns the CRC-32 checksum of data using the polynomial represented by the [Table].
func Checksum(data []byte, tab *Table) uint32
ChecksumIEEE returns the CRC-32 checksum of data using the [IEEE] polynomial.
func ChecksumIEEE(data []byte) uint32
MakeTable returns a [Table] constructed from the specified polynomial. The contents of this [Table] must not be modified.
func MakeTable(poly uint32) *Table
func (d *digest) MarshalBinary() ([]byte, error)
New creates a new [hash.Hash32] computing the CRC-32 checksum using the polynomial represented by the [Table]. Its Sum method will lay the value out in big-endian byte order. The returned Hash32 also implements [encoding.BinaryMarshaler] and [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal state of the hash.
func New(tab *Table) hash.Hash32
NewIEEE creates a new [hash.Hash32] computing the CRC-32 checksum using the [IEEE] polynomial. Its Sum method will lay the value out in big-endian byte order. The returned Hash32 also implements [encoding.BinaryMarshaler] and [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal state of the hash.
func NewIEEE() hash.Hash32
func (d *digest) Reset()
func (d *digest) Size() int
func (d *digest) Sum(in []byte) []byte
func (d *digest) Sum32() uint32
func (d *digest) UnmarshalBinary(b []byte) error
Update returns the result of adding the bytes in p to the crc.
func Update(crc uint32, tab *Table, p []byte) uint32
func (d *digest) Write(p []byte) (n int, err error)
func archAvailableCastagnoli() bool
func archAvailableCastagnoli() bool
func archAvailableCastagnoli() bool
func archAvailableCastagnoli() bool
func archAvailableCastagnoli() bool
func archAvailableCastagnoli() bool
func archAvailableIEEE() bool
func archAvailableIEEE() bool
func archAvailableIEEE() bool
func archAvailableIEEE() bool
func archAvailableIEEE() bool
func archAvailableIEEE() bool
func archInitCastagnoli()
func archInitCastagnoli()
func archInitCastagnoli()
func archInitCastagnoli()
func archInitCastagnoli()
func archInitCastagnoli()
func archInitIEEE()
func archInitIEEE()
func archInitIEEE()
func archInitIEEE()
func archInitIEEE()
func archInitIEEE()
func archUpdateCastagnoli(crc uint32, p []byte) uint32
func archUpdateCastagnoli(crc uint32, p []byte) uint32
func archUpdateCastagnoli(crc uint32, p []byte) uint32
archUpdateCastagnoli calculates the checksum of p using vectorizedCastagnoli.
func archUpdateCastagnoli(crc uint32, p []byte) uint32
func archUpdateCastagnoli(crc uint32, p []byte) uint32
func archUpdateCastagnoli(crc uint32, p []byte) uint32
func archUpdateIEEE(crc uint32, p []byte) uint32
archUpdateIEEE calculates the checksum of p using vectorizedIEEE.
func archUpdateIEEE(crc uint32, p []byte) uint32
func archUpdateIEEE(crc uint32, p []byte) uint32
archUpdateIEEE calculates the checksum of p using vectorizedIEEE.
func archUpdateIEEE(crc uint32, p []byte) uint32
func archUpdateIEEE(crc uint32, p []byte) uint32
func archUpdateIEEE(crc uint32, p []byte) uint32
castagnoliSSE42 is defined in crc32_amd64.s and uses the SSE 4.2 CRC32 instruction. go:noescape
func castagnoliSSE42(crc uint32, p []byte) uint32
castagnoliSSE42Triple is defined in crc32_amd64.s and uses the SSE 4.2 CRC32 instruction. go:noescape
func castagnoliSSE42Triple(crcA uint32, crcB uint32, crcC uint32, a []byte, b []byte, c []byte, rounds uint32) (retA uint32, retB uint32, retC uint32)
castagnoliShift computes the CRC32-C of K1 or K2 zeroes (depending on the table given) with the given initial crc value. This corresponds to CRC(crc, O) in the description in updateCastagnoli.
func castagnoliShift(table *sse42Table, crc uint32) uint32
func castagnoliUpdate(crc uint32, p []byte) uint32
func castagnoliUpdate(crc uint32, p []byte) uint32
ieeeCLMUL is defined in crc_amd64.s and uses the PCLMULQDQ instruction as well as SSE 4.1. go:noescape
func ieeeCLMUL(crc uint32, p []byte) uint32
func ieeeUpdate(crc uint32, p []byte) uint32
func ieeeUpdate(crc uint32, p []byte) uint32
go:noescape
func ppc64SlicingUpdateBy8(crc uint32, table8 *slicing8Table, p []byte) uint32
simpleMakeTable allocates and constructs a Table for the specified polynomial. The table is suitable for use with the simple algorithm (simpleUpdate).
func simpleMakeTable(poly uint32) *Table
simplePopulateTable constructs a Table for the specified polynomial, suitable for use with simpleUpdate.
func simplePopulateTable(poly uint32, t *Table)
simpleUpdate uses the simple algorithm to update the CRC, given a table that was previously computed using simpleMakeTable.
func simpleUpdate(crc uint32, tab *Table, p []byte) uint32
slicingMakeTable constructs a slicing8Table for the specified polynomial. The table is suitable for use with the slicing-by-8 algorithm (slicingUpdate).
func slicingMakeTable(poly uint32) *slicing8Table
slicingUpdate uses the slicing-by-8 algorithm to update the CRC, given a table that was previously computed using slicingMakeTable.
func slicingUpdate(crc uint32, tab *slicing8Table, p []byte) uint32
tableSum returns the IEEE checksum of table t.
func tableSum(t *Table) uint32
func update(crc uint32, tab *Table, p []byte, checkInitIEEE bool) uint32
this function requires the buffer to be 16 byte aligned and > 16 bytes long. go:noescape
func vectorCrc32(crc uint32, poly uint32, p []byte) uint32
vectorizedCastagnoli implements CRC32 using vector instructions. It is defined in crc32_s390x.s. go:noescape
func vectorizedCastagnoli(crc uint32, p []byte) uint32
vectorizedIEEE implements CRC32 using vector instructions. It is defined in crc32_s390x.s. go:noescape
func vectorizedIEEE(crc uint32, p []byte) uint32
Generated with Arrow