summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/prng/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/prng/rand.c')
-rw-r--r--libc-top-half/musl/src/prng/rand.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/prng/rand.c b/libc-top-half/musl/src/prng/rand.c
new file mode 100644
index 0000000..c000cd2
--- /dev/null
+++ b/libc-top-half/musl/src/prng/rand.c
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+#include <stdint.h>
+
+static uint64_t seed;
+
+void srand(unsigned s)
+{
+ seed = s-1;
+}
+
+int rand(void)
+{
+ seed = 6364136223846793005ULL*seed + 1;
+ return seed>>33;
+}