2 * UCW Library -- Unbiased Random Numbers
4 * (c) 1998--2006 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
14 /* We expect the random generator in libc to give at least 30 bits of randomness */
15 COMPILE_ASSERT(RAND_MAX_RANGE_TEST, RAND_MAX >= (1 << 30)-1);
20 return (random() & 0xffff) | ((random() & 0xffff) << 16);
28 ASSERT(max <= (1 << 30));
29 l = (RAND_MAX + 1U) - ((RAND_MAX + 1U) % max);
40 ((u64)(random() & 0xffff) << 48) |
41 ((u64)(random() & 0xffffff) << 24) |
42 (random() & 0xffffff);
46 random_max_u64(u64 max)
49 return random_max(max);
52 m = 0xffffffffffffffff;