File tree 4 files changed +6
-3
lines changed
4 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,13 @@ func fastrand() uint32 {
23
23
return xorshift32State
24
24
}
25
25
26
- func init () {
26
+ func initRand () {
27
27
r , _ := hardwareRand ()
28
28
xorshift64State = uint64 (r | 1 ) // protect against 0
29
29
xorshift32State = uint32 (xorshift64State )
30
30
}
31
31
32
- var xorshift32State uint32
32
+ var xorshift32State uint32 = 1
33
33
34
34
func xorshift32 (x uint32 ) uint32 {
35
35
// Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs".
@@ -49,7 +49,7 @@ func fastrand64() uint64 {
49
49
return xorshift64State
50
50
}
51
51
52
- var xorshift64State uint64
52
+ var xorshift64State uint64 = 1
53
53
54
54
// 64-bit xorshift multiply rng from http://vigna.di.unimi.it/ftp/papers/xorshift.pdf
55
55
func xorshiftMult64 (x uint64 ) uint64 {
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ func wasmEntryReactor() {
35
35
heapStart = uintptr (unsafe .Pointer (& heapStartSymbol ))
36
36
heapEnd = uintptr (wasm_memory_size (0 ) * wasmPageSize )
37
37
initHeap ()
38
+ initRand ()
38
39
39
40
if hasScheduler {
40
41
// A package initializer might do funky stuff like start a goroutine and
Original file line number Diff line number Diff line change @@ -247,6 +247,7 @@ func sleep(duration int64) {
247
247
// With a scheduler, init and the main function are invoked in a goroutine before starting the scheduler.
248
248
func run () {
249
249
initHeap ()
250
+ initRand ()
250
251
go func () {
251
252
initAll ()
252
253
callMain ()
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const hasParallelism = false
13
13
// With the "none" scheduler, init and the main function are invoked directly.
14
14
func run () {
15
15
initHeap ()
16
+ initRand ()
16
17
initAll ()
17
18
callMain ()
18
19
mainExited = true
You can’t perform that action at this time.
0 commit comments