From 0512fca3c22ee4257140a5eba0c993233c05febe Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 17 Dec 2018 02:03:42 +0100 Subject: [PATCH] [tests] use srand/rand on windows, declare mkstemp and srandom for c99 --- tests/utils_tests.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/utils_tests.h b/tests/utils_tests.h index af968b58..cf1a4460 100644 --- a/tests/utils_tests.h +++ b/tests/utils_tests.h @@ -55,21 +55,20 @@ #define RAND_MAX 32767 #endif -// are we on windows ? or are we using -std=c99 ? -#if defined(HAVE_WIN_HACKS) || defined(__STRICT_ANSI__) -// http://en.wikipedia.org/wiki/Linear_congruential_generator -// no srandom/random on win32 +#if defined(HAVE_WIN_HACKS) -uint_t srandom_seed = 1029; +// use srand/rand on windows +#define srandom srand +#define random rand -void srandom(uint_t new_seed) { - srandom_seed = new_seed; -} +#elif defined(__STRICT_ANSI__) + +// workaround to build with -std=c99 (for instance with older cygwin), +// assuming libbc is recent enough to supports these functions. +extern void srandom(unsigned); +extern int random(void); +extern char mkstemp(const char *pat); -uint_t random(void) { - srandom_seed = 1664525 * srandom_seed + 1013904223; - return srandom_seed; -} #endif void utils_init_random (void); -- 2.11.0