From 4f1b08903aa5a748e889ff08082515ed9e74c20f Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Thu, 3 Aug 2006 21:48:43 +0000 Subject: [PATCH] * m4/param.m4: Add support for MinGW. * src/base/random/cl_random_from.cc: Fix for last patch. --- ChangeLog | 5 +++++ m4/param.m4 | 4 ++-- src/base/random/cl_random_from.cc | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d28237..d67a5d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-08-03 Sheplyakov Alexei + + * m4/param.m4: Add support for MinGW. + * src/base/random/cl_random_from.cc: Fix for last patch. + 2006-07-23 Sheplyakov Alexei * src/base/random/cl_random_from.cc: Add support for MinGW. diff --git a/m4/param.m4 b/m4/param.m4 index 2a6b07d..21a7b84 100644 --- a/m4/param.m4 +++ b/m4/param.m4 @@ -31,9 +31,9 @@ CC=`echo "$CC " | sed -e 's/-O //g'` fi AC_TRY_EVAL(ac_link) CC="$ORIGCC" -if test -s conftest; then +if test -s conftest${ac_exeext}; then echo "creating $cl_machine_file_h" - ./conftest > conftest.h + ./conftest${ac_exeext} > conftest.h if cmp -s "$cl_machine_file_h" conftest.h 2>/dev/null; then # The file exists and we would not be changing it rm -f conftest.h diff --git a/src/base/random/cl_random_from.cc b/src/base/random/cl_random_from.cc index 0470a4e..eb9552a 100644 --- a/src/base/random/cl_random_from.cc +++ b/src/base/random/cl_random_from.cc @@ -1,5 +1,10 @@ // random_state constructor. + +#if defined(_WIN32) +#include // For GetCurrentProcessId(), must be included first, sorry. +#endif + // General includes. #include "cl_sysdep.h" @@ -9,10 +14,6 @@ // Implementation. -#if defined(_WIN32) -#include // for GetCurrentProcessId() -#endif - #include "cl_base_config.h" #include "cl_low.h" #include // declares rand() @@ -31,12 +32,14 @@ extern "C" int gettimeofday (struct timeval * tp, GETTIMEOFDAY_TZP_T tzp); #endif +namespace cln { inline uint32 get_seed (void) { var struct timeval tv; gettimeofday(&tv,0); - return cln::highlow32(tv.tv_sec,tv.tv_usec); // 16+16 zufällige Bits + return highlow32(tv.tv_sec,tv.tv_usec); // 16+16 zufällige Bits } +} // namespace cln #elif defined(HAVE_TIMES_CLOCK) @@ -67,7 +70,7 @@ inline uint32 get_seed (void) { struct timeb timebuf; ftime(&timebuf); - return cln::highlow32(timebuf.time, (long)(timebuf.millitm)*1000); + return highlow32(timebuf.time, (long)(timebuf.millitm)*1000); } } // namespace cln @@ -84,14 +87,14 @@ random_state::random_state () var uint32 seed_hi; var uint32 seed_lo; #if defined(unix) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(__CYGWIN__) && defined(__GNUC__)) || defined(__BEOS__) - seed_lo = ::get_seed(); + 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(__OpenBSD__) seed_lo = arc4random(); seed_hi = arc4random(); #elif defined(_WIN32) - seed_lo = ::get_seed(); + 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