From: Paul Brossier Date: Mon, 17 Dec 2018 01:03:42 +0000 (+0100) Subject: [tests] use srand/rand on windows, declare mkstemp and srandom for c99 X-Git-Tag: 0.4.9~86 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=0512fca3c22ee4257140a5eba0c993233c05febe;p=aubio.git [tests] use srand/rand on windows, declare mkstemp and srandom for c99 --- 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);