Debian Codegraph @

snappy/crc32c.h

raw
1 /**
2 * \file crc32c.h
3 * Functions and types for CRC checks.
4 *
5 * Generated on Wed Nov 7 16:14:52 2012,
6 * by pycrc v0.7.11, http://www.tty1.net/pycrc/
7 * using the configuration:
8 * Width = 32
9 * Poly = 0x1edc6f41
10 * XorIn = 0xffffffff
11 * ReflectIn = True
12 * XorOut = 0xffffffff
13 * ReflectOut = True
14 * Algorithm = table-driven
15 *****************************************************************************/
16 #ifndef __CRC32C_H__
17 #define __CRC32C_H__
18
19 #include <stdlib.h>
20 #include <stdint.h>
21
22 #if defined(_MSC_VER) && !defined(__cplusplus) /* Visual Studio */
23 #ifndef inline
24 #define inline __inline /* Visual C is not C99, but supports some kind of inline */
25 #endif
26 #endif
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32
33 /**
34 * The definition of the used algorithm.
35 *****************************************************************************/
36 #define CRC_ALGO_TABLE_DRIVEN 1
37
38
39 /**
40 * The type of the CRC values.
41 *
42 * This type must be big enough to contain at least 32 bits.
43 *****************************************************************************/
44 typedef uint32_t crc_t;
45
46
47 /**
48 * Reflect all bits of a \a data word of \a data_len bytes.
49 *
50 * \param data The data word to be reflected.
51 * \param data_len The width of \a data expressed in number of bits.
52 * \return The reflected data.
53 *****************************************************************************/
54 crc_t crc_reflect(crc_t data, size_t data_len);
55
56
57 /**
58 * Calculate the initial crc value.
59 *
60 * \return The initial crc value.
61 *****************************************************************************/
62 static inline crc_t crc_init(void)
63 {
64 return 0xffffffff;
65 }
66
67
68 /**
69 * Update the crc value with new data.
70 *
71 * \param crc The current crc value.
72 * \param data Pointer to a buffer of \a data_len bytes.
73 * \param data_len Number of bytes in the \a data buffer.
74 * \return The updated crc value.
75 *****************************************************************************/
76 crc_t crc_update(crc_t crc, const unsigned char *data, size_t data_len);
77
78
79 /**
80 * Calculate the final crc value.
81 *
82 * \param crc The current crc value.
83 * \return The final crc value.
84 *****************************************************************************/
85 static inline crc_t crc_finalize(crc_t crc)
86 {
87 return crc ^ 0xffffffff;
88 }
89
90
91 #ifdef __cplusplus
92 } /* closing brace for extern "C" */
93 #endif
94
95 #endif /* __CRC32C_H__ */