summaryrefslogtreecommitdiff
path: root/src/user/knob
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-02-16 22:26:47 -0500
committerBenji Dial <benji6283@gmail.com>2021-02-16 22:26:47 -0500
commitab4e1cfc8c587e4144d847bbd41307eff03130b2 (patch)
tree4e5502422977c747f3e65633ede26b73d9556ca1 /src/user/knob
parent2de07a2abea4081ebab6d80729e5665ba862c74c (diff)
downloadportland-os-ab4e1cfc8c587e4144d847bbd41307eff03130b2.tar.gz
rtc timestamp, knob rand, random terminal color
Diffstat (limited to 'src/user/knob')
-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