From 67faca7d9c54b367aee5fdeef2d5dd609fcf99d0 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 2 Nov 2015 14:09:24 -0500 Subject: runtime: break atomics out into package runtime/internal/atomic This change breaks out most of the atomics functions in the runtime into package runtime/internal/atomic. It adds some basic support in the toolchain for runtime packages, and also modifies linux/arm atomics to remove the dependency on the runtime's mutex. The mutexes have been replaced with spinlocks. all trybots are happy! In addition to the trybots, I've tested on the darwin/arm64 builder, on the darwin/arm builder, and on a ppc64le machine. Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f Reviewed-on: https://go-review.googlesource.com/14204 Run-TryBot: Michael Matloob Reviewed-by: Russ Cox --- src/runtime/runtime.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/runtime/runtime.go') diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index 81d3e5b3c3..0bbe42739d 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -4,7 +4,10 @@ package runtime -import _ "unsafe" // for go:linkname +import ( + "runtime/internal/atomic" + _ "unsafe" // for go:linkname +) //go:generate go run wincallback.go //go:generate go run mkduff.go @@ -20,7 +23,7 @@ var tls0 [8]uintptr // available storage for m0's TLS; not necessarily used; opa // Note: Called by runtime/pprof in addition to runtime code. func tickspersecond() int64 { - r := int64(atomicload64(&ticks.val)) + r := int64(atomic.Load64(&ticks.val)) if r != 0 { return r } @@ -39,7 +42,7 @@ func tickspersecond() int64 { if r == 0 { r++ } - atomicstore64(&ticks.val, uint64(r)) + atomic.Store64(&ticks.val, uint64(r)) } unlock(&ticks.lock) return r -- cgit v1.3