summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorSimon Rettberg2020-03-19 21:45:12 +0100
committerSimon Rettberg2020-03-19 21:45:12 +0100
commitbe628c705594a36f6aa649613ddf6c86039192a1 (patch)
tree6f29602c4327258fe63bc925752cab2d53dc54e4 /src/shared
parent[SERVER] crc32: Fix compile with optimizations (diff)
downloaddnbd3-be628c705594a36f6aa649613ddf6c86039192a1.tar.gz
dnbd3-be628c705594a36f6aa649613ddf6c86039192a1.tar.xz
dnbd3-be628c705594a36f6aa649613ddf6c86039192a1.zip
[SHARED] crc32: Don't skip table lookup if PCLMUL is unavailable
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/crc32.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/shared/crc32.c b/src/shared/crc32.c
index 098615f..c3e566f 100644
--- a/src/shared/crc32.c
+++ b/src/shared/crc32.c
@@ -682,19 +682,20 @@ uint32_t crc32(crc, buf, len)
c = crc32pclmul(c, buf, len & ~PCLMUL_ALIGN_MASK);
buf += len & ~PCLMUL_ALIGN_MASK;
len &= PCLMUL_ALIGN_MASK;
- }
-#else
- const uint32_t *buf4 = (const uint32_t *)(const void *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const uint8_t *)buf4;
+ } else
#endif
+ do {
+ const uint32_t *buf4 = (const uint32_t *)(const void *)buf;
+ while (len >= 32) {
+ DOLIT32;
+ len -= 32;
+ }
+ while (len >= 4) {
+ DOLIT4;
+ len -= 4;
+ }
+ buf = (const uint8_t *)buf4;
+ } while (0);
if (len) do {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);