summaryrefslogtreecommitdiff
path: root/src/user/knob/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/knob/rand.c')
-rw-r--r--src/user/knob/rand.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/user/knob/rand.c b/src/user/knob/rand.c
new file mode 100644
index 0000000..63648fb
--- /dev/null
+++ b/src/user/knob/rand.c
@@ -0,0 +1,19 @@
+#include <pland/syscall.h>
+#include <pland/pcrt.h>
+
+#include <stdint.h>
+
+static uint32_t r;
+
+static void seed_rand() {
+ r = _get_timestamp();
+}
+
+BEFORE_MAIN(seed_rand)
+
+uint32_t gen_rand() {
+ r ^= r << 13;
+ r ^= r >> 17;
+ r ^= r << 5;
+ return r;
+} \ No newline at end of file