summaryrefslogtreecommitdiff
path: root/lichen.c
diff options
context:
space:
mode:
Diffstat (limited to 'lichen.c')
-rw-r--r--lichen.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lichen.c b/lichen.c
new file mode 100644
index 0000000..f20c1b3
--- /dev/null
+++ b/lichen.c
@@ -0,0 +1,20 @@
+#include "lichen.h"
+
+
+void li_xorshift32_seed(struct li_xorshift32_t *xor, uint32_t seed) {
+ xor->state = seed ? seed : 1;
+ xor->generator.rand = li_xorshift32;
+ xor->generator.state = &(xor->state);
+}
+
+
+uint32_t li_xorshift32(void *s) {
+ uint64_t x = *((uint64_t*)s);
+ x ^= x >> 12;
+ x ^= x << 25;
+ x ^= x >> 27;
+ x *= 0x2545F4914F6CDD1DULL;
+ *((uint64_t*)s) = x;
+ // return just top 32 bits
+ return x >> 32;
+}