45#define log_rand log_debug
82 int line,
const char *file)
93 max =
size * divisor - 1;
103 if (++bailout > 10000) {
104 log_error(
"%s(%lu) = %lu bailout at %s:%d",
105 called_as, (
unsigned long)
size,
106 (
unsigned long) new_rand, file, line);
111 }
while (new_rand > max);
119 called_as, (
unsigned long)
size,
120 (
unsigned long) new_rand, file, line);
134 for (i = 1; i < 56; i++) {
151 for (i = 0; i < 10000; i++) {
179 log_rand(
"fc_rand_state J=%d K=%d X=%d",
181 for (i = 0; i < 8; i++) {
182 log_rand(
"fc_rand_state %d, %08x %08x %08x %08x %08x %08x %08x",
202 log_rand(
"fc_rand_set_state J=%d K=%d X=%d",
204 for (i = 0; i < 8; i++) {
205 log_rand(
"fc_rand_set_state %d, %08x %08x %08x %08x %08x %08x %08x",
223 int i, old_value = 0, new_value;
224 bool didchange, olddidchange =
FALSE;
225 int behaviourchange = 0, behavioursame = 0;
230 for (i = 0; i <
n+2; i++) {
233 didchange = (new_value != old_value);
235 if (didchange != olddidchange) {
241 olddidchange = didchange;
243 old_value = new_value;
245 log_test(
"test_random1(%d) same: %d, change: %d",
246 n, behavioursame, behaviourchange);
260 const char *called_as,
261 int line,
const char *file)
265#define LARGE_PRIME (10007)
266#define SMALL_PRIME (1009)
274 log_rand(
"%s(%lu,%lu) = %lu at %s:%d",
275 called_as, (
unsigned long) seed, (
unsigned long)
size,
276 (
unsigned long) result, file, line);
#define fc_assert_ret_val(condition, val)
#define log_error(message,...)
bool fc_rand_is_init(void)
RANDOM_STATE fc_rand_state(void)
RANDOM_TYPE fc_rand_debug(RANDOM_TYPE size, const char *called_as, int line, const char *file)
void fc_srand(RANDOM_TYPE seed)
RANDOM_TYPE fc_randomly_debug(RANDOM_TYPE seed, RANDOM_TYPE size, const char *called_as, int line, const char *file)
static RANDOM_STATE rand_state
void fc_rand_uninit(void)
void fc_rand_set_state(RANDOM_STATE state)