X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Frandom.c;h=016a17a2e2e39f5ff11482b12e7aa00ccb739843;hb=bc5f818d21b7aceaf2c0e263b00aa4295211d8f9;hp=bd9a1b30e52dda5d3e2d1b6f33f975f86729bdc9;hpb=1cf8ac51f5495ccd5187dc220ffc69e95d6e0cfc;p=libucw.git diff --git a/ucw/random.c b/ucw/random.c index bd9a1b30..016a17a2 100644 --- a/ucw/random.c +++ b/ucw/random.c @@ -7,23 +7,23 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" +#include #include /* We expect the random generator in libc to give at least 30 bits of randomness */ COMPILE_ASSERT(RAND_MAX_RANGE_TEST, RAND_MAX >= (1 << 30)-1); -uns +uint random_u32(void) { return (random() & 0xffff) | ((random() & 0xffff) << 16); } -uns -random_max(uns max) +uint +random_max(uint max) { - uns r, l; + uint r, l; ASSERT(max <= (1 << 30)); l = (RAND_MAX + 1U) - ((RAND_MAX + 1U) % max);