Fix undeterministic rol32 on ppc64, ppc64le, arm7 and s390x
authorJonathan Dieter <jdieter@gmail.com>
Wed, 1 Aug 2018 12:32:53 +0000 (13:32 +0100)
committerJonathan Dieter <jdieter@gmail.com>
Wed, 1 Aug 2018 12:32:53 +0000 (13:32 +0100)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
src/lib/buzhash/buzhash.c

index 3c35f5ee91f31977a053c5c6f1825f81126e2ef5..f3ed195edb930f3fbc4f13bf6f0d0a4b33775a77 100644 (file)
 
 #include <string.h>
 
-#define rol32(v,s) (((v) << (s)) | ((v) >> (32 - (s))))
+static uint32_t rol32(uint32_t v, uint32_t s) {
+    s %= 32;
+    if(s == 0)
+        return v;
+    return ((v << s) | (v >> (32 - s)));
+}
 
 const uint32_t buzhash_table[] = {
     0x458be752, 0xc10748cc, 0xfbbcdbb8, 0x6ded5b68,