/*
* Simple random number generator for testing.
- * Copyright © 2022-2023 Nick Bowler
+ * Copyright © 2022-2024 Nick Bowler
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <errno.h>
#include <limits.h>
-#include "test.h"
+#if !TEST_RNG_NO_EXTERNAL_API
+# include "test.h"
+#endif
#define B64(x) ((x) & 0xffffffffffffffff)
return z ^ (z >> 31);
}
+#if !TEST_RNG_NO_EXTERNAL_API
struct test_rng *test_rng_alloc(const char *seed_str)
{
unsigned long long seed;
limit |= (limit << 16 << 16);
if (!test_strtoumax(&seed_val, seed_str, limit)) {
- fprintf(stderr, "%s: invalid seed\n", seed_str);
+ print_error("%s: invalid seed", seed_str);
return NULL;
}
+ seed = seed_val;
rng = malloc_nofail(sizeof *rng);
rng->state[0] = splitmix64(&seed);
return val;
}
+#endif