From fb9fd2bdd7024e8d92e7c2a1436843cbca6e1ed1 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 17 Mar 2015 12:24:22 -0400 Subject: [PATCH] runtime: atomic ops for int64 These currently use portable implementations in terms of their uint64 counterparts. Change-Id: Icba5f7134cfcf9d0429edabcdd73091d97e5e905 Reviewed-on: https://go-review.googlesource.com/8831 Reviewed-by: Rick Hudson --- src/runtime/stubs.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go index 50e2a207da..6d5a98b5df 100644 --- a/src/runtime/stubs.go +++ b/src/runtime/stubs.go @@ -151,6 +151,22 @@ func atomicloaduintptr(ptr *uintptr) uintptr //go:noescape func atomicloaduint(ptr *uint) uint +// TODO: Write native implementations of int64 atomic ops (or improve +// inliner). These portable ones can't be inlined right now, so we're +// taking an extra function call hit. + +func atomicstoreint64(ptr *int64, new int64) { + atomicstore64((*uint64)(unsafe.Pointer(ptr)), uint64(new)) +} + +func atomicloadint64(ptr *int64) int64 { + return int64(atomicload64((*uint64)(unsafe.Pointer(ptr)))) +} + +func xaddint64(ptr *int64, delta int64) int64 { + return int64(xadd64((*uint64)(unsafe.Pointer(ptr)), delta)) +} + //go:noescape func setcallerpc(argp unsafe.Pointer, pc uintptr) -- 2.48.1