[cmake-developers] OpenBSD and srand()/rand() changes
Brad King
brad.king at kitware.com
Mon Dec 15 09:32:17 EST 2014
On 12/14/2014 08:36 AM, Rolf Eike Beer wrote:
> The idea behind this API in OpenBSD is: if you are looking for the pseudo
> numbers you need to call srand_deterministic(), i.e. you must explicitely
> state that you want the not really random random numbers. Everyone else will
> get real random.
CMake uses /dev/urandom on POSIX and wincrypt APIs on Windows to choose
the seed specifically to get "really" random behavior. The *only* reason
we continue to use s/rand() at all is to support the RANDOM_SEED API in
string(RANDOM), AFAIK.
One approach to dealing with this is to refactor the implementation of
string(RANDOM) to use non-deterministic APIs until RANDOM_SEED is used
and then use deterministic APIs after that. That will get better random
values by default but still honor the existing API when it is used.
-Brad
More information about the cmake-developers
mailing list