]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/crc32c_intel_fast.c
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / common / crc32c_intel_fast.c
1 #include "acconfig.h"
2 #include "include/int_types.h"
3 #include "common/crc32c_intel_baseline.h"
4
5 extern unsigned int crc32_iscsi_00(unsigned char const *buffer, int len, unsigned int crc);
6 extern unsigned int crc32_iscsi_zero_00(unsigned char const *buffer, int len, unsigned int crc);
7
8 #ifdef HAVE_GOOD_YASM_ELF64
9
10 uint32_t ceph_crc32c_intel_fast(uint32_t crc, unsigned char const *buffer, unsigned len)
11 {
12 uint32_t v;
13 unsigned left;
14
15
16 if (!buffer)
17 return crc32_iscsi_zero_00(buffer, len, crc);
18
19 /*
20 * the crc32_iscsi_00 method reads past buffer+len (because it
21 * reads full words) which makes valgrind unhappy. don't do
22 * that.
23 */
24 if (len < 16)
25 return ceph_crc32c_intel_baseline(crc, buffer, len);
26 left = ((unsigned long)buffer + len) & 7;
27 len -= left;
28 v = crc32_iscsi_00(buffer, len, crc);
29 if (left)
30 v = ceph_crc32c_intel_baseline(v, buffer + len, left);
31 return v;
32 }
33
34 int ceph_crc32c_intel_fast_exists(void)
35 {
36 return 1;
37 }
38
39 #else
40
41 int ceph_crc32c_intel_fast_exists(void)
42 {
43 return 0;
44 }
45
46 uint32_t ceph_crc32c_intel_fast(uint32_t crc, unsigned char const *buffer, unsigned len)
47 {
48 return 0;
49 }
50
51 #endif