runtime/internal/atomic: deduplicate And/Or code on wasm

When I initially added the wasm code for these ops I did not saw that
wasm actually has the Cas operations implemented, although they are
merely pointer assignments since wasm is single threaded.

Now with a generic implementation for And/Or we can add wasm to the
build tags.

For #61395
This commit is contained in:
Mauri de Souza Meneguzzo 2023-11-20 21:54:29 -03:00
parent cc7b4b3c36
commit 5188f46da5
2 changed files with 1 additions and 49 deletions

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build s390x || loong64 || mips || mipsle || mips64 || mips64le
//go:build s390x || loong64 || mips || mipsle || mips64 || mips64le || wasm
package atomic

View File

@ -339,51 +339,3 @@ func Xaddint64(ptr *int64, delta int64) int64 {
*ptr = new
return new
}
//go:nosplit
//go:noinline
func And32(ptr *uint32, val uint32) uint32 {
old := *ptr
*ptr = old & val
return old
}
//go:nosplit
//go:noinline
func And64(ptr *uint64, val uint64) uint64 {
old := *ptr
*ptr = old & val
return old
}
//go:nosplit
//go:noinline
func Anduintptr(ptr *uintptr, val uintptr) uintptr {
old := *ptr
*ptr = old & val
return old
}
//go:nosplit
//go:noinline
func Or32(ptr *uint32, val uint32) uint32 {
old := *ptr
*ptr = old | val
return old
}
//go:nosplit
//go:noinline
func Or64(ptr *uint64, val uint64) uint64 {
old := *ptr
*ptr = old | val
return old
}
//go:nosplit
//go:noinline
func Oruintptr(ptr *uintptr, val uintptr) uintptr {
old := *ptr
*ptr = old | val
return old
}