#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <inttypes.h>
#include <errno.h>
#include <limits.h>
#include <float.h>
return z ^ (z >> 31);
}
+#if HAVE_STRTOULL
+# define STRTOULL strtoull
+#elif HAVE___STRTOULL
+/* HP-UX 11 has __strtoull in <inttypes.h> */
+# 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;
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;