GCS  0.2.3
gu_crc32c.h
1 /*
2  * Copyright (C) 2013 Codership Oy <info@codership.com>
3  *
4  * @file Interface to CRC-32C implementation from www.evanjones.ca
5  *
6  * $Id: gu_crc32c.h 3281 2013-09-12 20:35:39Z alex $
7  */
8 
9 #ifndef _GU_CRC32C_H_
10 #define _GU_CRC32C_H_
11 
12 #if defined(__cplusplus)
13 extern "C" {
14 #endif
15 
16 #include "www.evanjones.ca/crc32c.h"
17 #include "gu_macros.h"
18 
20 extern void
21 gu_crc32c_configure();
22 
23 extern CRC32CFunctionPtr gu_crc32c_func;
24 
25 typedef uint32_t gu_crc32c_t;
26 
27 static gu_crc32c_t const GU_CRC32C_INIT = 0xFFFFFFFF;
28 
29 static GU_FORCE_INLINE void
30 gu_crc32c_init (gu_crc32c_t* crc)
31 {
32  *crc = GU_CRC32C_INIT;
33 }
34 
35 static GU_FORCE_INLINE void
36 gu_crc32c_append (gu_crc32c_t* crc, const void* data, size_t size)
37 {
38  *crc = gu_crc32c_func (*crc, data, size);
39 }
40 
41 static GU_FORCE_INLINE uint32_t
42 gu_crc32c_get (gu_crc32c_t crc)
43 {
44  return ~(crc);
45 }
46 
47 static GU_FORCE_INLINE uint32_t
48 gu_crc32c (const void* data, size_t size)
49 {
50  return ~(gu_crc32c_func (GU_CRC32C_INIT, data, size));
51 }
52 
53 #if defined(__cplusplus)
54 }
55 #endif
56 
57 #endif /* _GU_CRC32C_H_ */