Lines Matching refs:upper_bound
513 * Calculate a uniformly distributed random number less than upper_bound
517 * returned is outside the range [0, 2**32 % upper_bound). This
519 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
520 * after reduction modulo upper_bound.
523 arc4random_uniform(unsigned int upper_bound)
527 if (upper_bound < 2)
531 min = 0x100000000UL % upper_bound;
533 /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
534 if (upper_bound > 0x80000000)
535 min = 1 + ~upper_bound; /* 2**32 - upper_bound */
538 min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
554 return r % upper_bound;