github.com/sbinet/go@v0.0.0-20160827155028-54d7de7dd62b/src/hash/crc32/crc32_generic.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 !amd64,!amd64p32,!s390x
     6  
     7  package crc32
     8  
     9  // This file contains the generic version of updateCastagnoli which does
    10  // slicing-by-8, or uses the fallback for very small sizes.
    11  
    12  func castagnoliInitArch() (needGenericTables bool) {
    13  	return true
    14  }
    15  
    16  func updateCastagnoli(crc uint32, p []byte) uint32 {
    17  	// Use slicing-by-8 on larger inputs.
    18  	if len(p) >= sliceBy8Cutoff {
    19  		return updateSlicingBy8(crc, castagnoliTable8, p)
    20  	}
    21  	return update(crc, castagnoliTable, p)
    22  }
    23  
    24  func updateIEEE(crc uint32, p []byte) uint32 {
    25  	// Use slicing-by-8 on larger inputs.
    26  	if len(p) >= sliceBy8Cutoff {
    27  		ieeeTable8Once.Do(func() {
    28  			ieeeTable8 = makeTable8(IEEE)
    29  		})
    30  		return updateSlicingBy8(crc, ieeeTable8, p)
    31  	}
    32  	return update(crc, IEEETable, p)
    33  }