]> Cypherpunks repositories - gostls13.git/commit
runtime/internal/math: add multiplication with overflow check
authorMartin Möhrmann <moehrmann@google.com>
Sat, 27 Jan 2018 10:55:34 +0000 (11:55 +0100)
committerMartin Möhrmann <moehrmann@google.com>
Mon, 15 Oct 2018 17:58:06 +0000 (17:58 +0000)
commitc9130cae9a9cd59178e842851f3f30b1d97ab0bd
tree1c39f76c8b36dc646d7de76300065663daf67c86
parent240a30da1b3f5d4d60640a09f135275e8fee8b92
runtime/internal/math: add multiplication with overflow check

This CL adds a new internal math package for use by the runtime.
The new package exports a MulUintptr function with uintptr arguments
a and b and returns uintptr(a*b) and whether the full-width product
x*y does overflow the uintptr value range (uintptr(x*y) != x*y).

Uses of MulUinptr in the runtime and intrinsics for performance
will be added in followup CLs.

Updates #21588

Change-Id: Ia5a02eeabc955249118e4edf68c67d9fc0858058
Reviewed-on: https://go-review.googlesource.com/c/91755
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/inl_test.go
src/cmd/compile/internal/gc/racewalk.go
src/go/build/deps_test.go
src/runtime/internal/math/math.go [new file with mode: 0644]
src/runtime/internal/math/math_test.go [new file with mode: 0644]