1
/* crc32_braid_comb.c -- compute the CRC-32 of a data stream
2
* Copyright (C) 1995-2022 Mark Adler
3
* For conditions of distribution and use, see copyright notice in zlib.h
5
* This interleaved implementation of a CRC makes use of pipelined multiple
6
* arithmetic-logic units, commonly found in modern CPU cores. It is due to
7
* Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution.
12
#include "crc32_braid_p.h"
13
#include "crc32_braid_tbl.h"
14
#include "crc32_braid_comb_p.h"
16
/* ========================================================================= */
17
static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
18
return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
20
static uint32_t crc32_combine_gen_(z_off64_t len2) {
21
return x2nmodp(len2, 3);
23
static uint32_t crc32_combine_op_(uint32_t crc1, uint32_t crc2, const uint32_t op) {
24
return multmodp(op, crc1) ^ crc2;
27
/* ========================================================================= */
30
unsigned long Z_EXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) {
31
return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
33
unsigned long Z_EXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) {
34
return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
36
unsigned long Z_EXPORT PREFIX(crc32_combine_gen)(z_off_t len2) {
37
return crc32_combine_gen_(len2);
39
unsigned long Z_EXPORT PREFIX4(crc32_combine_gen)(z_off64_t len2) {
40
return crc32_combine_gen_(len2);
42
unsigned long Z_EXPORT PREFIX(crc32_combine_op)(unsigned long crc1, unsigned long crc2, const unsigned long op) {
43
return (unsigned long)crc32_combine_op_((uint32_t)crc1, (uint32_t)crc2, (uint32_t)op);
46
uint32_t Z_EXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
47
return crc32_combine_(crc1, crc2, len2);
49
uint32_t Z_EXPORT PREFIX(crc32_combine_gen)(z_off64_t len2) {
50
return crc32_combine_gen_(len2);
52
uint32_t Z_EXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t op) {
53
return crc32_combine_op_(crc1, crc2, op);
57
/* ========================================================================= */