aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/select.go
diff options
context:
space:
mode:
authorSokolov Yura <funny.falcon@gmail.com>2017-02-12 13:18:22 +0300
committerJosh Bleecher Snyder <josharian@gmail.com>2017-02-13 20:22:02 +0000
commit663226d8e130470c1a627c64cf489261ebb6da08 (patch)
tree4b0b301839ac054faf07a64cb664ce63c33dbdc4 /src/runtime/select.go
parent15c62e8535125f096c2425330fe9b561c38e7ee4 (diff)
downloadgo-663226d8e130470c1a627c64cf489261ebb6da08.tar.gz
go-663226d8e130470c1a627c64cf489261ebb6da08.zip
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>
Diffstat (limited to 'src/runtime/select.go')
-rw-r--r--src/runtime/select.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/select.go b/src/runtime/select.go
index 0d846b1470..4a744a1967 100644
--- a/src/runtime/select.go
+++ b/src/runtime/select.go
@@ -270,7 +270,7 @@ func selectgoImpl(sel *hselect) (uintptr, uint16) {
pollslice := slice{unsafe.Pointer(sel.pollorder), int(sel.ncase), int(sel.ncase)}
pollorder := *(*[]uint16)(unsafe.Pointer(&pollslice))
for i := 1; i < int(sel.ncase); i++ {
- j := int(fastrand()) % (i + 1)
+ j := fastrand() % uint32(i+1)
pollorder[i] = pollorder[j]
pollorder[j] = uint16(i)
}