]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: atomic ops for int64
authorAustin Clements <austin@google.com>
Tue, 17 Mar 2015 16:24:22 +0000 (12:24 -0400)
committerAustin Clements <austin@google.com>
Tue, 21 Apr 2015 15:34:54 +0000 (15:34 +0000)
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 <rlh@golang.org>
src/runtime/stubs.go

index 50e2a207dad2ee1b91333df69b9d495cba76f553..6d5a98b5dfe605740a81b11a380dfcfde026374e 100644 (file)
@@ -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)