--- src/base/random/cl_random_from.cc 2005-12-21 20:15:03.000000000 +0300 +++ src/base/random/cl_random_from.cc~ 2005-12-21 20:11:40.000000000 +0300 @@ -1,5 +1,9 @@ // random_state constructor. +#if defined(_WIN32) +#include // for GetCurrentProcessId() +#endif + // General includes. #include "cl_sysdep.h" @@ -11,12 +15,12 @@ #include "cl_base_config.h" #include "cl_low.h" +#include // declares rand() -#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(_WIN32) && defined(__GNUC__)) || defined(__BEOS__) +#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(__CYGWIN__) && defined(__GNUC__)) || defined(__BEOS__) #include #include // declares getpid() -#include // declares rand() #if defined(HAVE_GETTIMEOFDAY) @@ -52,8 +56,20 @@ #endif +#elif defined(_WIN32) +#include +#include + +inline uint32 get_seed (void) +{ + struct timeb timebuf; + ftime(&timebuf); + return cln::highlow32(timebuf.time, (long)(timebuf.millitm)*1000); +} + #endif + namespace cln { // Counter, to avoid that two random-states created immediately one after @@ -64,10 +80,13 @@ { var uint32 seed_hi; var uint32 seed_lo; -#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(_WIN32) && defined(__GNUC__)) || defined(__BEOS__) +#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(__CYGWIN) && defined(__GNUC__)) || defined(__BEOS__) seed_lo = ::get_seed(); seed_hi = (rand() // zuf�llige 31 Bit (bei UNIX_BSD) bzw. 16 Bit (bei UNIX_SYSV) << 8) ^ (uintL)(getpid()); // ca. 8 Bit von der Process ID +#elif defined(_WIN32) + seed_lo = ::get_seed(); + seed_hi = (rand() << 8) ^ (uintL)(GetCurrentProcessId()); #elif defined(__atarist) seed_lo = highlow32(GEMDOS_GetDate(),GEMDOS_GetTime()); // 16+16 zuf�llige Bits seed_hi = XBIOS_Random(); // 24 Bit zuf�llig vom XBIOS, vorne 8 Nullbits