aboutsummaryrefslogtreecommitdiffstats
path: root/lfsr2.c
diff options
context:
space:
mode:
Diffstat (limited to 'lfsr2.c')
-rw-r--r--lfsr2.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lfsr2.c b/lfsr2.c
new file mode 100644
index 0000000..5c40bf9
--- /dev/null
+++ b/lfsr2.c
@@ -0,0 +1,24 @@
+#include <linux/kernel.h>
+
+void mix_lfsr2(u32 h[4], const u32 v[4])
+{
+ size_t i;
+ u32 w;
+
+#define R(a) ({ \
+ u32 x = (a); \
+ x ^= rol32(x, 1) ^ rol32(x, 2); \
+ x ^= rol32(x, 7) ^ rol32(x, 14); \
+ x ^= rol32(x, 12) ^ rol32(x, 24); \
+ x; \
+})
+ for (i = 0; i < 4; ++i) {
+ h[0] ^= v[i];
+ w = R(h[0]) ^ (h[0] << 1) ^ (h[2] << 2) ^ R(h[3]);
+ h[0] = h[1];
+ h[1] = h[2];
+ h[2] = h[3];
+ h[3] = w;
+ }
+#undef R
+}