|
|
|||
File indexing completed on 2026-05-10 08:44:29
0001 //===-- llvm/Support/CRC.h - Cyclic Redundancy Check-------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file contains implementations of CRC functions. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_SUPPORT_CRC_H 0014 #define LLVM_SUPPORT_CRC_H 0015 0016 #include "llvm/Support/DataTypes.h" 0017 0018 namespace llvm { 0019 template <typename T> class ArrayRef; 0020 0021 // Compute the CRC-32 of Data. 0022 uint32_t crc32(ArrayRef<uint8_t> Data); 0023 0024 // Compute the running CRC-32 of Data, with CRC being the previous value of the 0025 // checksum. 0026 uint32_t crc32(uint32_t CRC, ArrayRef<uint8_t> Data); 0027 0028 // Class for computing the JamCRC. 0029 // 0030 // We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties 0031 // of this CRC: 0032 // Width : 32 0033 // Poly : 04C11DB7 0034 // Init : FFFFFFFF 0035 // RefIn : True 0036 // RefOut : True 0037 // XorOut : 00000000 0038 // Check : 340BC6D9 (result of CRC for "123456789") 0039 // 0040 // In other words, this is the same as CRC-32, except that XorOut is 0 instead 0041 // of FFFFFFFF. 0042 // 0043 // N.B. We permit flexibility of the "Init" value. Some consumers of this need 0044 // it to be zero. 0045 class JamCRC { 0046 public: 0047 JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {} 0048 0049 // Update the CRC calculation with Data. 0050 void update(ArrayRef<uint8_t> Data); 0051 0052 uint32_t getCRC() const { return CRC; } 0053 0054 private: 0055 uint32_t CRC; 0056 }; 0057 0058 } // end namespace llvm 0059 0060 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|