compat: backport to FreeBSD 12.1

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-03-18 09:00:38 -06:00
parent 3874141edd
commit 367c27cb02
1 changed files with 18 additions and 1 deletions

View File

@ -67,5 +67,22 @@ static inline void taskqgroup_drain_all(struct taskqgroup *tqg)
gtaskqueue_drain_all(q);
}
}
#endif
#if __FreeBSD_version < 1202000
static inline uint32_t arc4random_uniform(uint32_t bound)
{
uint32_t ret, max_mod_bound;
if (bound < 2)
return 0;
max_mod_bound = (1 + ~bound) % bound;
do {
ret = arc4random();
} while (ret < max_mod_bound);
return ret % bound;
}
#endif