Alexei, I wasn't aware of you having such a patch. Have you ever sent it to me? Sheplyakov Alexei wrote:
------------------------------------------------------------------------
--- 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 <windows.h> // for GetCurrentProcessId() +#endif + // General includes. #include "cl_sysdep.h"
@@ -11,12 +15,12 @@
#include "cl_base_config.h" #include "cl_low.h" +#include <cstdlib> // 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 <sys/types.h> #include <unistd.h> // declares getpid() -#include <cstdlib> // declares rand()
#if defined(HAVE_GETTIMEOFDAY)
@@ -52,8 +56,20 @@
#endif
+#elif defined(_WIN32) +#include <sys/time.h> +#include <sys/timeb.h> + +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
------------------------------------------------------------------------
But before commiting this, let me ask: is the handling of preprocessor macros really correct? In particular I'm wondering about your removal of one #if defined(__CYGWIN__) and the addition of an #if defined(__CYGWIN) in another place. I'm going to check this in to CVS ASAP if you can confirm that this won't break anything. Cheers -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>