reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Crc32.hxx
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////
2// Crc32.h
3// Copyright (c) 2011-2019 Stephan Brumme. All rights reserved.
4// Slicing-by-16 contributed by Bulat Ziganshin
5// Tableless bytewise CRC contributed by Hagai Gold
6// see http://create.stephan-brumme.com/disclaimer.html
7//
8
9/* from LICENSE in the repository:
10
11zlib License
12
13Copyright (c) 2011-2016 Stephan Brumme
14
15This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
16Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
171. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
18 If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
192. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
203. This notice may not be removed or altered from any source distribution.
21
22*/
23
24// if running on an embedded system, you might consider shrinking the
25// big Crc32Lookup table by undefining these lines:
26#define CRC32_USE_LOOKUP_TABLE_BYTE
27#define CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
28#define CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
29#define CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
30// - crc32_bitwise doesn't need it at all
31// - crc32_halfbyte has its own small lookup table
32// - crc32_1byte_tableless and crc32_1byte_tableless2 don't need it at all
33// - crc32_1byte needs only Crc32Lookup[0]
34// - crc32_4bytes needs only Crc32Lookup[0..3]
35// - crc32_8bytes needs only Crc32Lookup[0..7]
36// - crc32_4x8bytes needs only Crc32Lookup[0..7]
37// - crc32_16bytes needs all of Crc32Lookup
38// using the aforementioned #defines the table is automatically fitted to your needs
39
40// uint8_t, uint32_t, int32_t
41#include <stdint.h>
42// size_t
43#include <cstddef>
44
45// crc32_fast selects the fastest algorithm depending on flags (CRC32_USE_LOOKUP_...)
47uint32_t crc32_fast (const void* data, size_t length, uint32_t previousCrc32 = 0);
48
51
53uint32_t crc32_bitwise (const void* data, size_t length, uint32_t previousCrc32 = 0);
55uint32_t crc32_halfbyte(const void* data, size_t length, uint32_t previousCrc32 = 0);
56
57#ifdef CRC32_USE_LOOKUP_TABLE_BYTE
59uint32_t crc32_1byte (const void* data, size_t length, uint32_t previousCrc32 = 0);
60#endif
61
63uint32_t crc32_1byte_tableless (const void* data, size_t length, uint32_t previousCrc32 = 0);
65uint32_t crc32_1byte_tableless2(const void* data, size_t length, uint32_t previousCrc32 = 0);
66
67#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
69uint32_t crc32_4bytes (const void* data, size_t length, uint32_t previousCrc32 = 0);
70#endif
71
72#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
74uint32_t crc32_8bytes (const void* data, size_t length, uint32_t previousCrc32 = 0);
76uint32_t crc32_4x8bytes(const void* data, size_t length, uint32_t previousCrc32 = 0);
77#endif
78
79#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
81uint32_t crc32_16bytes (const void* data, size_t length, uint32_t previousCrc32 = 0);
83uint32_t crc32_16bytes_prefetch(const void* data, size_t length, uint32_t previousCrc32 = 0, size_t prefetchAhead = 256);
84#endif
uint32_t crc32_1byte_tableless2(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (byte algorithm) without lookup tables
Definition Crc32.cxx:246
uint32_t crc32_1byte(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (standard algorithm)
Definition Crc32.cxx:178
uint32_t crc32_4x8bytes(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (Slicing-by-8 algorithm), unroll inner loop 4 times
Definition Crc32.cxx:355
uint32_t crc32_bitwise(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (bitwise algorithm)
Definition Crc32.cxx:126
uint32_t crc32_combine(uint32_t crcA, uint32_t crcB, size_t lengthB)
merge two CRC32 such that result = crc32(dataB, lengthB, crc32(dataA, lengthA))
Definition Crc32.cxx:575
uint32_t crc32_16bytes_prefetch(const void *data, size_t length, uint32_t previousCrc32=0, size_t prefetchAhead=256)
compute CRC32 (Slicing-by-16 algorithm, prefetch upcoming data blocks)
Definition Crc32.cxx:481
uint32_t crc32_1byte_tableless(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (byte algorithm) without lookup tables
Definition Crc32.cxx:192
uint32_t crc32_halfbyte(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (half-byte algoritm)
Definition Crc32.cxx:153
uint32_t crc32_fast(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 using the fastest algorithm for large datasets on modern CPUs
Definition Crc32.cxx:558
uint32_t crc32_16bytes(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (Slicing-by-16 algorithm)
Definition Crc32.cxx:410
uint32_t crc32_4bytes(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (Slicing-by-4 algorithm)
Definition Crc32.cxx:273
uint32_t crc32_8bytes(const void *data, size_t length, uint32_t previousCrc32=0)
compute CRC32 (Slicing-by-8 algorithm)
Definition Crc32.cxx:310
unsigned int uint32_t
Definition stdint.h:85
void list()
Definition userAdmin.cxx:66