aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgc.go
diff options
context:
space:
mode:
authorRuslan Andreev <ruslan.andreev@huawei.com>2021-01-13 22:36:19 +0800
committerKeith Randall <khr@golang.org>2021-04-05 15:56:14 +0000
commitaf1789a61c02fa769fcd4ab8addcbb9a160b987b (patch)
tree4650a9edcb748b903dfef7362dd3f2171690088a /src/runtime/mgc.go
parenta4b8241d97fb180e1b9cb41c4828345c931d1aaf (diff)
downloadgo-af1789a61c02fa769fcd4ab8addcbb9a160b987b.tar.gz
go-af1789a61c02fa769fcd4ab8addcbb9a160b987b.zip
runtime: extend internal atomics to comply with sync/atomic
The CV add changes according to TODO in Go source-code. Internal atomic set does not comply with sync/atomic library and has shortage operations for signed integers. This patch extend internal atomic set by Int32 and Int64 operations. It's implemented new aliases and asm versions of operations. As a result Cas64 was replaced by Casint64 in findRunnableGCWorker without type casting. Another purpose is unified structure of internal atomics' source code. Before, assembly impementations for different archs were in different files. For example, filename for AMD64 was asm_amd64.s, but filename for RISC-V was atomic_riscv64.s. Some arches have both files without any meaning. So, assembly files were merged and renamed to atomic_{$ARCH}.s filenames. Change-Id: I29a05a7cbf5f4a9cc146e8315536c038af545677 Reviewed-on: https://go-review.googlesource.com/c/go/+/289152 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/runtime/mgc.go')
-rw-r--r--src/runtime/mgc.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 4895fa5ef6..4c165ddcdb 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -759,8 +759,7 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
return false
}
- // TODO: having atomic.Casint64 would be more pleasant.
- if atomic.Cas64((*uint64)(unsafe.Pointer(ptr)), uint64(v), uint64(v-1)) {
+ if atomic.Casint64(ptr, v, v-1) {
return true
}
}