From 159c42498365913f6ed400e13c77798d041a7d43 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 4 Feb 2019 15:33:35 -0500 Subject: add rand-{path,erand48}, minor fixes --- km-rand.c | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) (limited to 'km-rand.c') diff --git a/km-rand.c b/km-rand.c index bb3a2cc..e777069 100644 --- a/km-rand.c +++ b/km-rand.c @@ -31,56 +31,3 @@ km_rand_fini( rs->cbs->fini(rs); } } - -// libc random source get_floats -static bool -rand_libc_get_floats( - km_rand_t * const rs, - const size_t num_vals, - float * const vals -) { - UNUSED(rs); - - // generate results - for (size_t i = 0; i < num_vals; i++) { - vals[i] = 1.0 * rand() / RAND_MAX; - } - - // return success - return true; -} - -// fill sizes callback for system random source -static bool -rand_libc_get_sizes( - km_rand_t * const rs, - const size_t num_vals, - size_t * const vals -) { - UNUSED(rs); - - // generate results - for (size_t i = 0; i < num_vals; i++) { - vals[i] = rand(); - } - - // return success - return true; -} - -// system random source callbacks -static const km_rand_cbs_t -RAND_LIBC_CBS = { - .get_floats = rand_libc_get_floats, - .get_sizes = rand_libc_get_sizes, - .fini = NULL, -}; - -// init system random source (uses system rand()) -void -km_rand_init_libc( - km_rand_t * const rs -) { - rs->cbs = &RAND_LIBC_CBS; - rs->data = NULL; -} -- cgit v1.2.3