]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef CEPH_CRC32C_H |
2 | #define CEPH_CRC32C_H | |
3 | ||
4 | #include <stdint.h> | |
5 | ||
6 | typedef uint32_t (*ceph_crc32c_func_t)(uint32_t crc, unsigned char const *data, unsigned length); | |
7 | ||
8 | /* | |
9 | * this is a static global with the chosen crc32c implementation for | |
10 | * the given architecture. | |
11 | */ | |
12 | extern ceph_crc32c_func_t ceph_crc32c_func; | |
13 | ||
14 | extern ceph_crc32c_func_t ceph_choose_crc32(void); | |
15 | ||
16 | /** | |
17 | * calculate crc32c | |
18 | * | |
19 | * Note: if the data pointer is NULL, we calculate a crc value as if | |
20 | * it were zero-filled. | |
21 | * | |
22 | * @param crc initial value | |
23 | * @param data pointer to data buffer | |
24 | * @param length length of buffer | |
25 | */ | |
26 | static inline uint32_t ceph_crc32c(uint32_t crc, unsigned char const *data, unsigned length) | |
27 | { | |
28 | return ceph_crc32c_func(crc, data, length); | |
29 | } | |
30 | ||
31 | #endif |