From 383b447e0da5bd1fcdc2439230b5a1d3e3402117 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 28 Jun 2019 16:44:07 +0000 Subject: 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 Reviewed-by: Keith Randall --- src/runtime/stack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 463f3bf3fd..68b24432a4 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -337,7 +337,7 @@ func stackalloc(n uint32) stack { } if debug.efence != 0 || stackFromSystem != 0 { - n = uint32(round(uintptr(n), physPageSize)) + n = uint32(alignUp(uintptr(n), physPageSize)) v := sysAlloc(uintptr(n), &memstats.stacks_sys) if v == nil { throw("out of memory (stackalloc)") -- cgit v1.3