From ab4e1cfc8c587e4144d847bbd41307eff03130b2 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 16 Feb 2021 22:26:47 -0500 Subject: rtc timestamp, knob rand, random terminal color --- src/user/knob/rand.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/user/knob/rand.c (limited to 'src/user/knob/rand.c') 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 +#include + +#include + +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 -- cgit v1.2.3