Browse Source

* m4/param.m4: Add support for MinGW.

* src/base/random/cl_random_from.cc: Fix for last patch.
master
Richard Kreckel 19 years ago
parent
commit
4f1b08903a
  1. 5
      ChangeLog
  2. 4
      m4/param.m4
  3. 19
      src/base/random/cl_random_from.cc

5
ChangeLog

@ -1,3 +1,8 @@
2006-08-03 Sheplyakov Alexei <varg@theor.jinr.ru>
* m4/param.m4: Add support for MinGW.
* src/base/random/cl_random_from.cc: Fix for last patch.
2006-07-23 Sheplyakov Alexei <varg@theor.jinr.ru>
* src/base/random/cl_random_from.cc: Add support for MinGW.

4
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

19
src/base/random/cl_random_from.cc

@ -1,5 +1,10 @@
// random_state constructor.
#if defined(_WIN32)
#include <windows.h> // For GetCurrentProcessId(), must be included first, sorry.
#endif
// General includes.
#include "cl_sysdep.h"
@ -9,10 +14,6 @@
// Implementation.
#if defined(_WIN32)
#include <windows.h> // for GetCurrentProcessId()
#endif
#include "cl_base_config.h"
#include "cl_low.h"
#include <cstdlib> // 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

Loading…
Cancel
Save