[ros-diffs] [turner] 23791: Better rand() implementation. This should fix the problem where you get 0 every time you use rand()

turner at svn.reactos.org turner at svn.reactos.org
Wed Aug 30 00:27:49 CEST 2006


Author: turner
Date: Wed Aug 30 02:27:48 2006
New Revision: 23791

URL: http://svn.reactos.org/svn/reactos?rev=23791&view=rev
Log:
Better rand() implementation.  This should fix the problem where you get 0 every time you use rand()

Modified:
    trunk/reactos/lib/crt/misc/tls.c
    trunk/reactos/lib/crt/stdlib/rand.c

Modified: trunk/reactos/lib/crt/misc/tls.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/crt/misc/tls.c?rev=23791&r1=23790&r2=23791&view=diff
==============================================================================
--- trunk/reactos/lib/crt/misc/tls.c (original)
+++ trunk/reactos/lib/crt/misc/tls.c Wed Aug 30 02:27:48 2006
@@ -13,6 +13,8 @@
    ThreadData->tdoserrno = 0;
 
    ThreadData->fpecode = 0;
+
+   ThreadData->tnext = 1;
 
    /* FIXME: init more thread local data */
 

Modified: trunk/reactos/lib/crt/stdlib/rand.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/crt/stdlib/rand.c?rev=23791&r1=23790&r2=23791&view=diff
==============================================================================
--- trunk/reactos/lib/crt/stdlib/rand.c (original)
+++ trunk/reactos/lib/crt/stdlib/rand.c Wed Aug 30 02:27:48 2006
@@ -11,7 +11,7 @@
 {
   PTHREADDATA ThreadData = GetThreadData();
 
-  ThreadData->tnext = ThreadData->tnext * 0x5deece66dLL + 11;
+  ThreadData->tnext = ThreadData->tnext * 0x5deece66dLL + 2531011;
   return (int)((ThreadData->tnext >> 16) & RAND_MAX);
 }
 




More information about the Ros-diffs mailing list