Lines Matching defs:upper_bound
262 * Calculate a uniformly distributed random number less than upper_bound
266 * returned is outside the range [0, 2**32 % upper_bound). This
268 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
269 * after reduction modulo upper_bound.
272 arc4random_uniform(u_int32_t upper_bound)
276 if (upper_bound < 2)
280 min = 0x100000000UL % upper_bound;
282 /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
283 if (upper_bound > 0x80000000)
284 min = 1 + ~upper_bound; /* 2**32 - upper_bound */
287 min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
303 return r % upper_bound;