aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mfinal.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-06-28 16:44:07 +0000
committerMichael Knyszek <mknyszek@google.com>2019-11-04 23:41:34 +0000
commit383b447e0da5bd1fcdc2439230b5a1d3e3402117 (patch)
treec1dafd5c18d1d2ddc09d51dc6892087e3f506411 /src/runtime/mfinal.go
parent2566e21f243387156e8e7f2acad0ce14d9712bbc (diff)
downloadgo-383b447e0da5bd1fcdc2439230b5a1d3e3402117.tar.gz
go-383b447e0da5bd1fcdc2439230b5a1d3e3402117.zip
runtime: clean up power-of-two rounding code with align functions
This change renames the "round" function to the more appropriately named "alignUp" which rounds an integer up to the next multiple of a power of two. This change also adds the alignDown function, which is almost like alignUp but rounds down to the previous multiple of a power of two. With these two functions, we also go and replace manual rounding code with it where we can. Change-Id: Ie1487366280484dcb2662972b01b4f7135f72fec Reviewed-on: https://go-review.googlesource.com/c/go/+/190618 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/mfinal.go')
-rw-r--r--src/runtime/mfinal.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go
index 37b2c381dd..d6c85a8b93 100644
--- a/src/runtime/mfinal.go
+++ b/src/runtime/mfinal.go
@@ -407,9 +407,9 @@ okarg:
// compute size needed for return parameters
nret := uintptr(0)
for _, t := range ft.out() {
- nret = round(nret, uintptr(t.align)) + uintptr(t.size)
+ nret = alignUp(nret, uintptr(t.align)) + uintptr(t.size)
}
- nret = round(nret, sys.PtrSize)
+ nret = alignUp(nret, sys.PtrSize)
// make sure we have a finalizer goroutine
createfing()