util/rand_xor: use getrandom() when available
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Wed, 18 Sep 2019 11:20:57 +0000 (13:20 +0200)
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Fri, 15 May 2020 11:37:20 +0000 (13:37 +0200)
commit4c212a1168de9ffc83a7b8e8751ea7cf3dca5c4a
treeae08aa9420c0587a99ca21214fcd59270b8ef958
parentcf2b285c5592e5d8fce24ab6a34eaa9c168aa129
util/rand_xor: use getrandom() when available

This function has been added in glibc 2.25, and the related syscall in
Linux 3.17, in order to avoid requiring the /dev/urandom to exist, and
doing the open()/read()/close() dance on it.

We pass GRND_NONBLOCK so that it doesn’t block if not enough entropy has
been gathered to initialise the /dev/urandom source, and fallback to the
next source in any error case.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2026>
meson.build
src/util/rand_xor.c