aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2025-10-29 13:37:52 -0400
committerGopher Robot <gobot@golang.org>2025-10-30 09:55:06 -0700
commitd32b1f02c3e869b6ddf73d2113477b1fd77d42c8 (patch)
tree074df75ed82ee3790fd4a4232a07754ad2693a3b /src/runtime/runtime_test.go
parentcbbd385cb863e4a0969de9846fdd80227ed91ad0 (diff)
downloadgo-d32b1f02c3e869b6ddf73d2113477b1fd77d42c8.tar.xz
runtime: delete timediv
Now that the compiler handles constant 64-bit divisions without function calls on 32-bit systems, we no longer need to maintain and test a bad custom implementation of 64-bit division. Change-Id: If28807ad4f86507267ae69bc8f0b09ec18e98b66 Reviewed-on: https://go-review.googlesource.com/c/go/+/716463 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/runtime/runtime_test.go')
-rw-r--r--src/runtime/runtime_test.go76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/runtime/runtime_test.go b/src/runtime/runtime_test.go
index 6c628f8903..c1c63e3cea 100644
--- a/src/runtime/runtime_test.go
+++ b/src/runtime/runtime_test.go
@@ -6,7 +6,6 @@ package runtime_test
import (
"flag"
- "fmt"
"internal/asan"
"internal/cpu"
"internal/msan"
@@ -498,81 +497,6 @@ func TestVersion(t *testing.T) {
}
}
-func TestTimediv(t *testing.T) {
- for _, tc := range []struct {
- num int64
- div int32
- ret int32
- rem int32
- }{
- {
- num: 8,
- div: 2,
- ret: 4,
- rem: 0,
- },
- {
- num: 9,
- div: 2,
- ret: 4,
- rem: 1,
- },
- {
- // Used by runtime.check.
- num: 12345*1000000000 + 54321,
- div: 1000000000,
- ret: 12345,
- rem: 54321,
- },
- {
- num: 1<<32 - 1,
- div: 2,
- ret: 1<<31 - 1, // no overflow.
- rem: 1,
- },
- {
- num: 1 << 32,
- div: 2,
- ret: 1<<31 - 1, // overflow.
- rem: 0,
- },
- {
- num: 1 << 40,
- div: 2,
- ret: 1<<31 - 1, // overflow.
- rem: 0,
- },
- {
- num: 1<<40 + 1,
- div: 1 << 10,
- ret: 1 << 30,
- rem: 1,
- },
- } {
- name := fmt.Sprintf("%d div %d", tc.num, tc.div)
- t.Run(name, func(t *testing.T) {
- // Double check that the inputs make sense using
- // standard 64-bit division.
- ret64 := tc.num / int64(tc.div)
- rem64 := tc.num % int64(tc.div)
- if ret64 != int64(int32(ret64)) {
- // Simulate timediv overflow value.
- ret64 = 1<<31 - 1
- rem64 = 0
- }
- if ret64 != int64(tc.ret) {
- t.Errorf("%d / %d got ret %d rem %d want ret %d rem %d", tc.num, tc.div, ret64, rem64, tc.ret, tc.rem)
- }
-
- var rem int32
- ret := Timediv(tc.num, tc.div, &rem)
- if ret != tc.ret || rem != tc.rem {
- t.Errorf("timediv %d / %d got ret %d rem %d want ret %d rem %d", tc.num, tc.div, ret, rem, tc.ret, tc.rem)
- }
- })
- }
-}
-
func BenchmarkProcYield(b *testing.B) {
benchN := func(n uint32) func(*testing.B) {
return func(b *testing.B) {