shithub: aubio

Download patch

ref: 0512fca3c22ee4257140a5eba0c993233c05febe
parent: c0a1906a54c8d2e58f708408c72cbf0b6aa534c8
author: Paul Brossier <piem@piem.org>
date: Sun Dec 16 21:03:42 EST 2018

[tests] use srand/rand on windows, declare mkstemp and srandom for c99

--- 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__)
 
-uint_t random(void) {
-    srandom_seed = 1664525 * srandom_seed + 1013904223;
-    return srandom_seed;
-}
+// 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);
+
 #endif
 
 void utils_init_random (void);