Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / crc32c_intel_fast.c
1 #include "acconfig.h"
2 #include "common/crc32c_intel_baseline.h"
3
4 extern unsigned int crc32_iscsi_00(unsigned char const *buffer, int len, unsigned int crc);
5 extern unsigned int crc32_iscsi_zero_00(unsigned char const *buffer, int len, unsigned int crc);
6
7 #ifdef HAVE_GOOD_YASM_ELF64
8
9 uint32_t ceph_crc32c_intel_fast(uint32_t crc, unsigned char const *buffer, unsigned len)
10 {
11         uint32_t v;
12         unsigned left;
13
14         if (!buffer)
15         {
16           return crc32_iscsi_zero_00(buffer, len, crc);
17         }
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