summaryrefslogtreecommitdiffstats
path: root/osdep/io.c
diff options
context:
space:
mode:
authorLeo Izen <leo.izen@gmail.com>2022-08-14 21:28:54 -0400
committerLeo Izen <leo.izen@gmail.com>2022-08-17 10:21:55 -0400
commit52e7269ea633b7ac3d83d7b5cba9b15c5fbcbef9 (patch)
tree89b68afb896b8b50a304b5bc79625775d4ba3252 /osdep/io.c
parent813164cc07124aabfbc4aa3b8f9fe33fe222c77c (diff)
downloadmpv-52e7269ea633b7ac3d83d7b5cba9b15c5fbcbef9.tar.bz2
mpv-52e7269ea633b7ac3d83d7b5cba9b15c5fbcbef9.tar.xz
misc/random: add xoshiro random number implementation
Add xoshiro as a PRNG implementation instead of relying on srand() and rand() from the C standard library. This, in particular, lets us avoid platform-defined behavior with respect to threading.
Diffstat (limited to 'osdep/io.c')
-rw-r--r--osdep/io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/osdep/io.c b/osdep/io.c
index d4dcfc6fba..ec55aa2647 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -32,6 +32,7 @@
#include "mpv_talloc.h"
#include "config.h"
+#include "misc/random.h"
#include "osdep/io.h"
#include "osdep/terminal.h"
@@ -804,7 +805,7 @@ int mp_mkostemps(char *template, int suffixlen, int flags)
for (size_t fuckshit = 0; fuckshit < UINT32_MAX; fuckshit++) {
// Using a random value may make it require fewer iterations (even if
// not truly random; just a counter would be sufficient).
- size_t fuckmess = rand();
+ size_t fuckmess = mp_rand_next();
char crap[7] = "";
snprintf(crap, sizeof(crap), "%06zx", fuckmess);
memcpy(t, crap, 6);