stas            Fri Mar  7 03:36:58 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/standard       php_rand.h 
  Log:
  improve seed calculation 
  # better solution would be to port mt's multi-value seed procedure
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/php_rand.h?r1=1.28.2.1.2.1.2.1&r2=1.28.2.1.2.1.2.2&diff_format=u
Index: php-src/ext/standard/php_rand.h
diff -u php-src/ext/standard/php_rand.h:1.28.2.1.2.1.2.1 
php-src/ext/standard/php_rand.h:1.28.2.1.2.1.2.2
--- php-src/ext/standard/php_rand.h:1.28.2.1.2.1.2.1    Mon Dec 31 07:17:15 2007
+++ php-src/ext/standard/php_rand.h     Fri Mar  7 03:36:58 2008
@@ -20,7 +20,7 @@
    | Based on code from: Shawn Cokus <[EMAIL PROTECTED]>          |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_rand.h,v 1.28.2.1.2.1.2.1 2007/12/31 07:17:15 sebastian Exp $ */
+/* $Id: php_rand.h,v 1.28.2.1.2.1.2.2 2008/03/07 03:36:58 stas Exp $ */
 
 #ifndef PHP_RAND_H
 #define        PHP_RAND_H
@@ -47,9 +47,9 @@
 #define PHP_MT_RAND_MAX ((long) (0x7FFFFFFF)) /* (1<<31) - 1 */ 
 
 #ifdef PHP_WIN32
-#define GENERATE_SEED() ((long) (time(0) * GetCurrentProcessId() * 1000000 * 
php_combined_lcg(TSRMLS_C)))
+#define GENERATE_SEED() (((long) (time(0) * GetCurrentProcessId())) ^ ((long) 
(1000000.0 * php_combined_lcg(TSRMLS_C))))
 #else
-#define GENERATE_SEED() ((long) (time(0) * getpid() * 1000000 * 
php_combined_lcg(TSRMLS_C)))
+#define GENERATE_SEED() (((long) (time(0) * getpid())) ^ ((long) (1000000.0 * 
php_combined_lcg(TSRMLS_C)))))
 #endif
 
 PHPAPI void php_srand(long seed TSRMLS_DC);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to