Lines Matching refs:upper_bound
107 * Calculate a uniformly distributed random number less than upper_bound
111 * returned is outside the range [0, 2**32 % upper_bound). This
113 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
114 * after reduction modulo upper_bound.
117 arc4random_uniform(u_int32_t upper_bound)
121 if (upper_bound < 2)
125 min = 0x100000000UL % upper_bound;
127 /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
128 if (upper_bound > 0x80000000)
129 min = 1 + ~upper_bound; /* 2**32 - upper_bound */
132 min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
148 return r % upper_bound;