diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-12-07 05:10:21 +0300 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-12-17 19:12:41 +0300 |
commit | 39f8c7961dcd530e88d13c600145097106647d2e (patch) | |
tree | 0519a50d0ca6c71a57b98525a3b8ef0bd74bf244 /libavutil/random_seed.c | |
parent | 7b880464cb31b779259d56123e03cf3903d476e5 (diff) |
lavu/random_seed: use arc4random() when available
arc4random() was designed as a superior interface for system random
number generation, designed for OpenBSD and subsequently incorporated by
other BSD's, Mac OS X, and some non-standard libc's. It is thus an improvement to
use it whenever available.
As a side note, this may or may not get included in glibc, and there is
a proposal to create a posix_random family based on these ideas:
http://austingroupbugs.net/view.php?id=859.
Tested on Mac OS X.
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavutil/random_seed.c')
-rw-r--r-- | libavutil/random_seed.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 8aa8c3879b..205a636f92 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -121,6 +121,10 @@ uint32_t av_get_random_seed(void) } #endif +#if HAVE_ARC4RANDOM + return arc4random(); +#endif + if (read_random(&seed, "/dev/urandom") == sizeof(seed)) return seed; if (read_random(&seed, "/dev/random") == sizeof(seed)) |