roken: use Win32 rand_s() for rk_random() when available
commit4cf66ae8e4341b02d45ddba9cf860c79e731b3fb
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 11 Apr 2015 05:25:55 +0000 (11 01:25 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 11 Apr 2015 05:35:32 +0000 (11 01:35 -0400)
treee307b47c98793b3fc1c874d790ee16edc73ba0a1
parent0de18bdb5fa3881e65d780a0a77e31df7833ea9a
roken: use Win32 rand_s() for rk_random() when available

On Windows if the compiler and C RTL is >= 1400 then the rand_s()
function is available.  rand_s() unlike rand() makes use of the
RtlGenRandom() API to produce a random number between 0 and UINT_MAX.
If rand_s() is not available or fails, fallback to rand().

One of the benefits of rand_s() is that no initialization is required
so it will provide random output even if rk_random_init() is not called.

Change-Id: I2768155de744bd49604fc8237728bb205d637f2a
lib/roken/rand.c
lib/roken/roken.h.in