1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:26:49 -07:00
go/test/fixedbugs/issue16241_64.go
Jorropo e30ce3c498 sync/atomic: make intrinsics noescape except 64bits op on 32bits arch and unsafe.Pointer
Fixes #16241

I made 64 bits op on 32 bits arches still leak since it was kinda promised.

The promised leaks were wider than this but I don't belive it's effect can
be observed in an breaking maner without using unsafe the way it's currently
setup.

Change-Id: I66d8df47bfe49bce3efa64ac668a2a55f70733a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/462298
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-15 17:11:46 +00:00

47 lines
1.1 KiB
Go

//go:build !(386 || arm || mips || mipsle)
// errorcheck -0 -m -l
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package foo
import "sync/atomic"
func AddInt64(x *int64) { // ERROR "x does not escape$"
atomic.AddInt64(x, 42)
}
func AddUint64(x *uint64) { // ERROR "x does not escape$"
atomic.AddUint64(x, 42)
}
func CompareAndSwapInt64(x *int64) { // ERROR "x does not escape$"
atomic.CompareAndSwapInt64(x, 42, 42)
}
func CompareAndSwapUint64(x *uint64) { // ERROR "x does not escape$"
atomic.CompareAndSwapUint64(x, 42, 42)
}
func LoadInt64(x *int64) { // ERROR "x does not escape$"
atomic.LoadInt64(x)
}
func LoadUint64(x *uint64) { // ERROR "x does not escape$"
atomic.LoadUint64(x)
}
func StoreInt64(x *int64) { // ERROR "x does not escape$"
atomic.StoreInt64(x, 42)
}
func StoreUint64(x *uint64) { // ERROR "x does not escape$"
atomic.StoreUint64(x, 42)
}
func SwapInt64(x *int64) { // ERROR "x does not escape$"
atomic.SwapInt64(x, 42)
}
func SwapUint64(x *uint64) { // ERROR "x does not escape$"
atomic.SwapUint64(x, 42)
}