rand: remove fallback code
This was in place to allow users with Go versions prior to the math/bits
package to use rand. The code in rng.go now uses math/bits, so the
separation is no longer justified.
Change-Id: I99be8d6e3b39bf7981f0ed85bd418e7902064468
Reviewed-on: https://go-review.googlesource.com/c/exp/+/208917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/rand/rng.go b/rand/rng.go
index f59fadb..f4b0e19 100644
--- a/rand/rng.go
+++ b/rand/rng.go
@@ -53,3 +53,17 @@
// XOR high and low 64 bits together and rotate right by high 6 bits of state.
return bits.RotateLeft64(pcg.high^pcg.low, -int(pcg.high>>58))
}
+
+func (pcg *PCGSource) add() {
+ var carry uint64
+ pcg.low, carry = bits.Add64(pcg.low, incLow, 0)
+ pcg.high, _ = bits.Add64(pcg.high, incHigh, carry)
+}
+
+func (pcg *PCGSource) multiply() {
+ hi, lo := bits.Mul64(pcg.low, mulLow)
+ hi += pcg.high * mulLow
+ hi += pcg.low * mulHigh
+ pcg.low = lo
+ pcg.high = hi
+}
diff --git a/rand/uint64.go b/rand/uint64.go
deleted file mode 100644
index cc1fc01..0000000
--- a/rand/uint64.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build go1.12
-
-package rand
-
-import "math/bits"
-
-func (pcg *PCGSource) add() {
- var carry uint64
- pcg.low, carry = bits.Add64(pcg.low, incLow, 0)
- pcg.high, _ = bits.Add64(pcg.high, incHigh, carry)
-}
-
-func (pcg *PCGSource) multiply() {
- hi, lo := bits.Mul64(pcg.low, mulLow)
- hi += pcg.high * mulLow
- hi += pcg.low * mulHigh
- pcg.low = lo
- pcg.high = hi
-}
diff --git a/rand/uint64_fallback.go b/rand/uint64_fallback.go
deleted file mode 100644
index 58f66cf..0000000
--- a/rand/uint64_fallback.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !go1.12
-
-package rand
-
-func (pcg *PCGSource) add() {
- old := pcg.low
- pcg.low += incLow
- if pcg.low < old {
- // Carry occurred.
- pcg.high++
- }
- pcg.high += incHigh
-}
-
-func (pcg *PCGSource) multiply() {
- // Break each lower word into two separate 32-bit 'digits' each stored
- // in a 64-bit word with 32 high zero bits. This allows the overflow
- // into the high word to be computed.
- s0 := (pcg.low >> 00) & maxUint32
- s1 := (pcg.low >> 32) & maxUint32
-
- const (
- m0 = (multiplier >> 00) & maxUint32
- m1 = (multiplier >> 32) & maxUint32
- mLow = multiplier & (1<<64 - 1)
- mHigh = multiplier >> 64 & (1<<64 - 1)
- )
-
- high := pcg.low*mHigh + pcg.high*mLow
- s0m0 := s0 * m0
- s0m1 := s0 * m1
- s1m0 := s1 * m0
- s1m1 := s1 * m1
- high += (s0m1 >> 32) + (s1m0 >> 32)
- carry := (s0m1 & maxUint32) + (s1m0 & maxUint32) + s0m0>>32
- high += (carry >> 32)
-
- pcg.low *= mLow
- pcg.high = high + s1m1
-}