X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..ca66cea69e6e866fd781ae2260d9474bdd48f2ca:/bsd/libkern/random.c?ds=sidebyside diff --git a/bsd/libkern/random.c b/bsd/libkern/random.c index cb2b6ec9d..920ae5c60 100644 --- a/bsd/libkern/random.c +++ b/bsd/libkern/random.c @@ -62,6 +62,8 @@ #include #include +#include +#include /* * Pseudo-random number generator for randomizing the profiling clock, @@ -69,8 +71,10 @@ * [0, 2^31 - 1]. */ u_long -random() +random(void) { - return RandomULong(); + /* Zero all but bottom 31 bits, also works for 64-bit longs */ + u_long mask = (u_long)-1 >> ((sizeof(u_long) * 8) - 31); + return (mask & RandomULong()); }