summaryrefslogtreecommitdiff
path: root/ext/standard/lcg.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/lcg.c')
-rw-r--r--ext/standard/lcg.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/standard/lcg.c b/ext/standard/lcg.c
index ad9c4744f8..aa0adff2fb 100644
--- a/ext/standard/lcg.c
+++ b/ext/standard/lcg.c
@@ -78,7 +78,7 @@ static void lcg_seed(TSRMLS_D) /* {{{ */
struct timeval tv;
if (gettimeofday(&tv, NULL) == 0) {
- LCG(s1) = tv.tv_sec ^ (~tv.tv_usec);
+ LCG(s1) = tv.tv_sec ^ (tv.tv_usec<<11);
} else {
LCG(s1) = 1;
}
@@ -88,6 +88,11 @@ static void lcg_seed(TSRMLS_D) /* {{{ */
LCG(s2) = (long) getpid();
#endif
+ /* Add entropy to s2 by calling gettimeofday() again */
+ if (gettimeofday(&tv, NULL) == 0) {
+ LCG(s2) ^= (tv.tv_usec<<11);
+ }
+
LCG(seeded) = 1;
}
/* }}} */