github.com/primecitizens/pcz/std@v0.2.1/core/atomic/stubs.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2015 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build !wasm 9 10 package atomic 11 12 import "unsafe" 13 14 // PublicationBarrier performs a store/store barrier (a "publication" 15 // or "export" barrier). Some form of synchronization is required 16 // between initializing an object and making that object accessible to 17 // another processor. Without synchronization, the initialization 18 // writes and the "publication" write may be reordered, allowing the 19 // other processor to follow the pointer and observe an uninitialized 20 // object. In general, higher-level synchronization should be used, 21 // such as locking or an atomic pointer write. publicationBarrier is 22 // for when those aren't an option, such as in the implementation of 23 // the memory manager. 24 // 25 // There's no corresponding barrier for the read side because the read 26 // side naturally has a data dependency order. All architectures that 27 // Go supports or seems likely to ever support automatically enforce 28 // data dependency ordering. 29 func PublicationBarrier() 30 31 // 32 // Store 33 // 34 35 //go:noescape 36 func StoreInt32(ptr *int32, new int32) 37 38 //go:noescape 39 func StoreInt64(ptr *int64, new int64) 40 41 //go:noescape 42 func StoreUintptr(ptr *uintptr, new uintptr) 43 44 // TODO(matloob): Should these functions have the go:noescape annotation? 45 46 // 47 // Load 48 // 49 50 //go:noescape 51 func LoadUintptr(ptr *uintptr) uintptr 52 53 //go:noescape 54 func LoadUint(ptr *uint) uint 55 56 //go:noescape 57 func LoadInt32(ptr *int32) int32 58 59 //go:noescape 60 func LoadInt64(ptr *int64) int64 61 62 // 63 // Swap 64 // 65 66 //go:noescape 67 func SwapInt32(ptr *int32, new int32) int32 68 69 //go:noescape 70 func SwapInt64(ptr *int64, new int64) int64 71 72 // 73 // Add 74 // 75 76 //go:noescape 77 func AddInt32(ptr *int32, delta int32) int32 78 79 //go:noescape 80 func AddInt64(ptr *int64, delta int64) int64 81 82 // 83 // Compare and swap 84 // 85 86 //go:noescape 87 func Cas32(ptr *uint32, old, new uint32) bool 88 89 //go:noescape 90 func CasUintptr(ptr *uintptr, old, new uintptr) bool 91 92 // NO go:noescape annotation; see atomic_pointer.go. 93 func CasUnsafePointer(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool 94 95 //go:noescape 96 func CasInt32(ptr *int32, old, new int32) bool 97 98 //go:noescape 99 func CasInt64(ptr *int64, old, new int64) bool