X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/88c05279e142ff97db82c30f4f3936b1ea5eb22a..8ba5dbed14fc225893f8ad4b935e0e4b9f77db78:/test/rng.c diff --git a/test/rng.c b/test/rng.c index 884d981..d86b623 100644 --- a/test/rng.c +++ b/test/rng.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,19 @@ static unsigned long long splitmix64(unsigned long long *state) return z ^ (z >> 31); } +#if HAVE_STRTOULL +# define STRTOULL strtoull +#elif HAVE___STRTOULL +/* HP-UX 11 has __strtoull in */ +# define STRTOULL __strtoull +#else +/* + * Just fall back to strtoul -- in the worst case we just lose the ability + * to set all 64 bits of the seed. + */ +# define STRTOULL strtoul +#endif + struct test_rng *test_rng_alloc(const char *seed_str) { unsigned long long seed; @@ -78,7 +92,7 @@ struct test_rng *test_rng_alloc(const char *seed_str) char *end; errno = 0; - seed = strtoull(seed_str, &end, 0); + seed = STRTOULL(seed_str, &end, 0); if (*end != 0) { fprintf(stderr, "%s: invalid seed\n", seed_str); return NULL;