From 14d0d4161dc7161f324cd8a8b51396e9576ab9fa Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 17 May 2011 17:03:32 +0000 Subject: [PATCH] 2011-05-17 19:02 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * include/harbour.hbx * src/rtl/hbrandom.c + HB_RAND32() -> <32-bit random number> ; TOFIX: random numbers are broken under mingw 4.5.2, only high 16bits are random. in all HB_RAND*() functions --- harbour/ChangeLog | 8 ++++++++ harbour/include/harbour.hbx | 1 + harbour/src/rtl/hbrandom.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 391e480466..2c014271e9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2011-05-17 19:02 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * include/harbour.hbx + * src/rtl/hbrandom.c + + HB_RAND32() -> <32-bit random number> + + ; TOFIX: random numbers are broken under mingw 4.5.2, only high 16bits are random. + in all HB_RAND*() functions + 2011-05-17 17:48 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg ! escape fn passed to upx diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index c81738ed1b..a0b4cd48de 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -691,6 +691,7 @@ DYNAMIC HB_PROCESSVALUE DYNAMIC HB_PROGNAME DYNAMIC HB_PS DYNAMIC HB_PVALUE +DYNAMIC HB_RAND32 DYNAMIC HB_RANDOM DYNAMIC HB_RANDOMINT DYNAMIC HB_RANDOMSEED diff --git a/harbour/src/rtl/hbrandom.c b/harbour/src/rtl/hbrandom.c index 5de4e95eab..9455b1bb8e 100644 --- a/harbour/src/rtl/hbrandom.c +++ b/harbour/src/rtl/hbrandom.c @@ -118,6 +118,11 @@ HB_FUNC( HB_RANDOMINT ) } } +HB_FUNC( HB_RAND32 ) /* returns an integer between 0 and 0xFFFFFFFF (inclusive) */ +{ + hb_retnint( ( HB_MAXINT ) ( hb_random_num() * ( HB_MAXINT ) HB_U32_MAX ) ); +} + HB_FUNC( HB_RANDOMSEED ) { srand( HB_ISNUM( 1 ) ? ( unsigned ) hb_parni( 1 ) : ( unsigned ) hb_dateMilliSeconds() );