1 //===-- llvm/Support/CRC.h - Cyclic Redundancy Check-------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains implementations of CRC functions.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_SUPPORT_CRC_H
14 #define LLVM_SUPPORT_CRC_H
16 #include "llvm/Support/DataTypes.h"
19 template <typename T
> class ArrayRef
;
21 // Compute the CRC-32 of Data.
22 uint32_t crc32(ArrayRef
<uint8_t> Data
);
24 // Compute the running CRC-32 of Data, with CRC being the previous value of the
26 uint32_t crc32(uint32_t CRC
, ArrayRef
<uint8_t> Data
);
28 // Class for computing the JamCRC.
30 // We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties
38 // Check : 340BC6D9 (result of CRC for "123456789")
40 // In other words, this is the same as CRC-32, except that XorOut is 0 instead
43 // N.B. We permit flexibility of the "Init" value. Some consumers of this need
47 JamCRC(uint32_t Init
= 0xFFFFFFFFU
) : CRC(Init
) {}
49 // Update the CRC calculation with Data.
50 void update(ArrayRef
<uint8_t> Data
);
52 uint32_t getCRC() const { return CRC
; }
58 } // end namespace llvm