[cmake-developers] OpenBSD and srand()/rand() changes

Rolf Eike Beer eike at sf-mail.de
Mon Dec 15 11:48:21 EST 2014


Brad King wrote:
> 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.

Which is what we would get if we do not call srand_deterministic() on OpenBSD 
afaict. We would get weaker random numbers on other platforms, but I doubt 
this matters at all.

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20141215/8293df2d/attachment.sig>


More information about the cmake-developers mailing list