X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..cc8bc92ae4a8e9f1a1ab61bf83d34ad8150b3405:/bsd/libkern/random.c diff --git a/bsd/libkern/random.c b/bsd/libkern/random.c index cb2b6ec9d..070080f90 100644 --- a/bsd/libkern/random.c +++ b/bsd/libkern/random.c @@ -62,15 +62,19 @@ #include #include +#include +#include /* * Pseudo-random number generator for randomizing the profiling clock, * and whatever else we might use it for. The result is uniform on * [0, 2^31 - 1]. */ -u_long -random() +u_int32_t +random(void) { - return RandomULong(); + /* Zero all but bottom 31 bits, also works for 64-bit longs */ + u_int32_t mask = (u_int32_t)-1 >> ((sizeof(u_int32_t) * 8) - 31); + return (mask & RandomULong()); }