xref: /aosp_15_r20/external/lzma/CPP/Common/XzCrc64Reg.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // XzCrc64Reg.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "../../C/CpuArch.h"
6 #include "../../C/XzCrc64.h"
7 
8 #include "../Common/MyCom.h"
9 
10 #include "../7zip/Common/RegisterCodec.h"
11 
12 Z7_CLASS_IMP_COM_1(
13   CXzCrc64Hasher
14   , IHasher
15 )
16   UInt64 _crc;
17 public:
18   Byte _mtDummy[1 << 7];  // it's public to eliminate clang warning: unused private field
19 
20   CXzCrc64Hasher(): _crc(CRC64_INIT_VAL) {}
21 };
22 
23 Z7_COM7F_IMF2(void, CXzCrc64Hasher::Init())
24 {
25   _crc = CRC64_INIT_VAL;
26 }
27 
28 Z7_COM7F_IMF2(void, CXzCrc64Hasher::Update(const void *data, UInt32 size))
29 {
30   _crc = Crc64Update(_crc, data, size);
31 }
32 
33 Z7_COM7F_IMF2(void, CXzCrc64Hasher::Final(Byte *digest))
34 {
35   const UInt64 val = CRC64_GET_DIGEST(_crc);
36   SetUi64(digest, val)
37 }
38 
39 REGISTER_HASHER(CXzCrc64Hasher, 0x4, "CRC64", 8)
40