10 typedef uint32_t (*ceph_crc32c_func_t)(uint32_t crc, unsigned char const *data, unsigned length);
13 * this is a static global with the chosen crc32c implementation for
14 * the given architecture.
16 extern ceph_crc32c_func_t ceph_crc32c_func;
18 extern ceph_crc32c_func_t ceph_choose_crc32(void);
21 * calculate crc32c for data that is entirely 0 (ZERO)
23 * Note: works the same as ceph_crc32c_func for data == nullptr,
24 * but faster than the optimized assembly on certain architectures.
25 * This is faster than intel optimized assembly, but not as fast as
26 * ppc64le optimized assembly.
28 * @param crc initial value
29 * @param length length of buffer
31 uint32_t ceph_crc32c_zeros(uint32_t crc, unsigned length);
36 * Note: if the data pointer is NULL, we calculate a crc value as if
37 * it were zero-filled.
39 * @param crc initial value
40 * @param data pointer to data buffer
41 * @param length length of buffer
43 static inline uint32_t ceph_crc32c(uint32_t crc, unsigned char const *data, unsigned length)
46 if (!data && length > 16)
47 return ceph_crc32c_zeros(crc, length);
48 #endif /* HAVE_POWER8 */
50 return ceph_crc32c_func(crc, data, length);