diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2022-04-09 02:28:05 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2022-04-09 02:28:05 +0000 |
| commit | 4e75b40d8a96c5d51490ddea43566fe8e6d4168c (patch) | |
| tree | 06358f285c713a7f05297cb7d2826319d6561683 /src/librandom/random_uint32.c | |
| parent | 1fedaae65b56b8548cdf2d8c26e2becece5fec07 (diff) | |
| download | skalibs-4e75b40d8a96c5d51490ddea43566fe8e6d4168c.tar.gz | |
Prepare for 2.12.0.0. librandom revamp.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/librandom/random_uint32.c')
| -rw-r--r-- | src/librandom/random_uint32.c | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/src/librandom/random_uint32.c b/src/librandom/random_uint32.c deleted file mode 100644 index 6700879..0000000 --- a/src/librandom/random_uint32.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ISC license. */ - -#include <skalibs/sysdeps.h> - -#ifdef SKALIBS_HASARC4RANDOM - -#include <skalibs/nonposix.h> -#include <stdint.h> -#include <stdlib.h> -#include <skalibs/random.h> - -uint32_t random_uint32 (uint32_t n) -{ - return arc4random_uniform(n) ; -} - -#else - -#include <skalibs/uint32.h> -#include <skalibs/random.h> - -uint32_t random_uint32 (uint32_t n) -{ - uint32_t min, x ; - if (n < 2) return 0 ; - min = -n % n ; - for (;;) - { - char tmp[4] ; - random_string(tmp, 4) ; - uint32_unpack_big(tmp, &x) ; - if (x >= min) break ; - } - return x % n ; -} - -#endif |
