Lines Matching defs:upper_bound
504 * Calculate a uniformly distributed random number less than upper_bound
508 * returned is outside the range [0, 2**32 % upper_bound). This
510 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
511 * after reduction modulo upper_bound.
514 arc4random_uniform(unsigned int upper_bound)
518 if (upper_bound < 2)
522 min = 0x100000000UL % upper_bound;
524 /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
525 if (upper_bound > 0x80000000)
526 min = 1 + ~upper_bound; /* 2**32 - upper_bound */
529 min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
545 return r % upper_bound;