X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_random.c;h=5500aaa028113c62167fbf6434ceee21f23a05e4;hb=711f5b6c86f51061c21bedcaa46214a01de0125c;hp=cf926f9c81a150371d36af82547c6963ff92316f;hpb=c144ae4659e129a929afb67706a54604220fef43;p=collectd.git diff --git a/src/daemon/utils_random.c b/src/daemon/utils_random.c index cf926f9c..5500aaa0 100644 --- a/src/daemon/utils_random.c +++ b/src/daemon/utils_random.c @@ -31,8 +31,16 @@ #include +#ifdef WIN32 +double erand48(unsigned short unused[3]) { + return (double)rand() / (double)RAND_MAX; +} + +long int jrand48(unsigned short unused[3]) { return rand(); } +#endif + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -static _Bool have_seed = 0; +static bool have_seed; static unsigned short seed[3]; static void cdrand_seed(void) { @@ -47,7 +55,11 @@ static void cdrand_seed(void) { seed[1] = (unsigned short)(t >> 16); seed[2] = (unsigned short)(t >> 32); - have_seed = 1; +#ifdef WIN32 + srand((unsigned)t); +#endif + + have_seed = true; } double cdrand_d(void) {