aboutsummaryrefslogtreecommitdiff
path: root/common/xorshift.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/xorshift.c')
-rw-r--r--common/xorshift.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/xorshift.c b/common/xorshift.c
new file mode 100644
index 0000000..51f9c80
--- /dev/null
+++ b/common/xorshift.c
@@ -0,0 +1,12 @@
+
+#include "xorshift.h"
+
+uint32_t xorshift32(uint32_t x)
+{
+ /* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */
+ x ^= x << 13;
+ x ^= x >> 17;
+ x ^= x << 5;
+ return x;
+}
+