Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===-- llvm/Support/JamCRC.h - Cyclic Redundancy Check ---------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains an implementation of JamCRC. |
| 11 | // |
| 12 | // We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties |
| 13 | // of this CRC: |
| 14 | // Width : 32 |
| 15 | // Poly : 04C11DB7 |
| 16 | // Init : FFFFFFFF |
| 17 | // RefIn : True |
| 18 | // RefOut : True |
| 19 | // XorOut : 00000000 |
| 20 | // Check : 340BC6D9 (result of CRC for "123456789") |
| 21 | // |
| 22 | // N.B. We permit flexibility of the "Init" value. Some consumers of this need |
| 23 | // it to be zero. |
| 24 | // |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | |
| 27 | #ifndef LLVM_SUPPORT_JAMCRC_H |
| 28 | #define LLVM_SUPPORT_JAMCRC_H |
| 29 | |
| 30 | #include "llvm/Support/DataTypes.h" |
| 31 | |
| 32 | namespace llvm { |
| 33 | template <typename T> class ArrayRef; |
| 34 | |
| 35 | class JamCRC { |
| 36 | public: |
| 37 | JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {} |
| 38 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 39 | // Update the CRC calculation with Data. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 40 | void update(ArrayRef<char> Data); |
| 41 | |
| 42 | uint32_t getCRC() const { return CRC; } |
| 43 | |
| 44 | private: |
| 45 | uint32_t CRC; |
| 46 | }; |
| 47 | } // End of namespace llvm |
| 48 | |
| 49 | #endif |