mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-27 05:00:37 +00:00
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>
This commit is contained in:
parent
7b880464cb
commit
39f8c7961d
2
configure
vendored
2
configure
vendored
@ -1841,6 +1841,7 @@ MATH_FUNCS="
|
||||
SYSTEM_FUNCS="
|
||||
access
|
||||
aligned_malloc
|
||||
arc4random
|
||||
clock_gettime
|
||||
closesocket
|
||||
CommandLineToArgvW
|
||||
@ -5232,6 +5233,7 @@ check_func ${malloc_prefix}memalign && enable memalign
|
||||
check_func ${malloc_prefix}posix_memalign && enable posix_memalign
|
||||
|
||||
check_func access
|
||||
check_func arc4random
|
||||
check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
|
||||
check_func fcntl
|
||||
check_func fork
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user