aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu Wang <coolwanglu@gmail.com>2013-11-27 00:00:32 +0800
committerLu Wang <coolwanglu@gmail.com>2013-11-27 00:00:32 +0800
commit3e31f83ac762e34b266b7888aec161bb2b843dd1 (patch)
treef2dcc065ebc43df9ce74bf9984d48f0d83e790c5
parentb37cdde052d8da61d6a3d9c21359aaeee9dd7c60 (diff)
use js variable for rand_seed
-rw-r--r--src/library.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/library.js b/src/library.js
index d55f9c0c..7be3eef6 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3445,27 +3445,25 @@ LibraryManager.library = {
return limit;
},
- __rand_seed: 'allocate([0x0273459b, 0, 0, 0], "i32", ALLOC_STATIC)',
+ __rand_seed: 0x0273459b,
srand__deps: ['__rand_seed'],
srand: function(seed) {
- {{{ makeSetValue('___rand_seed', 0, 'seed', 'i32') }}}
+ ___rand_seed = seed;
},
rand_r__deps: ['__rand_seed'],
rand_r: function(seed) {
- var val = {{{ makeGetValue('___rand_seed', 0, 'i32') }}};
- // calculate val * 31010991 + 0x676e6177
+ // calculate __rand_seed * 31010991 + 0x676e6177
// i32 multiplication will be rounded by javascript
- var valh = val >> 16;
- var vall = val & 0xffff;
+ var seedh = ___rand_seed >> 16;
+ var seedl = ___rand_seed & 0xffff;
var c = 31010991;
var ch = c >> 16;
var cl = c & 0xffff;
- val = (((valh * cl + vall * ch) << 16) + vall * cl + 0x676e6177) & 0x7fffffff;
+ ___rand_seed = (((seedh * cl + seedl * ch) << 16) + seedl * cl + 0x676e6177) & 0x7fffffff;
- {{{ makeSetValue('___rand_seed', 0, 'val', 'i32') }}}
- return val;
+ return ___rand_seed;
},
rand__deps: ['rand_r'],
rand: function() {