Lines Matching refs:ceil
53 u32 __get_random_u32_below(u32 ceil);
60 static inline u32 get_random_u32_below(u32 ceil) in get_random_u32_below() argument
62 if (!__builtin_constant_p(ceil)) in get_random_u32_below()
63 return __get_random_u32_below(ceil); in get_random_u32_below()
73 BUILD_BUG_ON_MSG(!ceil, "get_random_u32_below() must take ceil > 0"); in get_random_u32_below()
74 if (ceil <= 1) in get_random_u32_below()
77 if (ceil <= 1U << 8) { in get_random_u32_below()
78 u32 mult = ceil * get_random_u8(); in get_random_u32_below()
79 if (likely(is_power_of_2(ceil) || (u8)mult >= (1U << 8) % ceil)) in get_random_u32_below()
81 } else if (ceil <= 1U << 16) { in get_random_u32_below()
82 u32 mult = ceil * get_random_u16(); in get_random_u32_below()
83 if (likely(is_power_of_2(ceil) || (u16)mult >= (1U << 16) % ceil)) in get_random_u32_below()
86 u64 mult = (u64)ceil * get_random_u32(); in get_random_u32_below()
87 if (likely(is_power_of_2(ceil) || (u32)mult >= -ceil % ceil)) in get_random_u32_below()
110 static inline u32 get_random_u32_inclusive(u32 floor, u32 ceil) in get_random_u32_inclusive() argument
112 BUILD_BUG_ON_MSG(__builtin_constant_p(floor) && __builtin_constant_p(ceil) && in get_random_u32_inclusive()
113 (floor > ceil || ceil - floor == U32_MAX), in get_random_u32_inclusive()
115 return floor + get_random_u32_below(ceil - floor + 1); in get_random_u32_inclusive()