]> Cypherpunks repositories - gostls13.git/commit
runtime: make fastrand to generate 32bit values
authorSokolov Yura <funny.falcon@gmail.com>
Sun, 12 Feb 2017 10:18:22 +0000 (13:18 +0300)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 13 Feb 2017 20:22:02 +0000 (20:22 +0000)
commit663226d8e130470c1a627c64cf489261ebb6da08
tree4b0b301839ac054faf07a64cb664ce63c33dbdc4
parent15c62e8535125f096c2425330fe9b561c38e7ee4
runtime: make fastrand to generate 32bit values

Extend period of fastrand from (1<<31)-1 to (1<<32)-1 by
choosing other polynom and reacting on high bit before shift.

Polynomial is taken at https://users.ece.cmu.edu/~koopman/lfsr/index.html
from 32.dat.gz . It is referred as F7711115 cause this list of
polynomials is for LFSR with shift to right (and fastrand uses shift to
left). (old polynomial is referred in 31.dat.gz as 7BB88888).

There were couple of places with conversation of fastrand to int, which
leads to negative values on 32bit platforms. They are fixed.

Change-Id: Ibee518a3f9103e0aea220ada494b3aec77babb72
Reviewed-on: https://go-review.googlesource.com/36875
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/malloc.go
src/runtime/select.go
src/runtime/stubs.go