• Martin Möhrmann's avatar
    runtime/internal/math: add multiplication with overflow check · c9130cae
    Martin Möhrmann authored
    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: 's avatarKeith Randall <khr@golang.org>
    c9130cae
math.go 550 Bytes