github.com/primecitizens/pcz/std@v0.2.1/core/atomic/atomic_arm64.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 arm64 9 10 package atomic 11 12 import ( 13 "unsafe" 14 15 "github.com/primecitizens/pcz/std/core/cpu" 16 ) 17 18 var ( 19 useARM64Atomics bool 20 ) 21 22 func init() { 23 useARM64Atomics = cpu.ARM64.HasAll(cpu.ARM64Feature_atomics) 24 } 25 26 // 27 // Store 28 // 29 30 //go:noescape 31 func Store8(ptr *uint8, val uint8) 32 33 //go:noescape 34 func Store32(ptr *uint32, val uint32) 35 36 //go:noescape 37 func Store64(ptr *uint64, val uint64) 38 39 // NO go:noescape annotation; see atomic_pointer.go. 40 func StorePointer(ptr unsafe.Pointer, val unsafe.Pointer) 41 42 // 43 // StoreRel 44 // 45 46 //go:noescape 47 func StoreRel32(ptr *uint32, val uint32) 48 49 //go:noescape 50 func StoreRel64(ptr *uint64, val uint64) 51 52 //go:noescape 53 func StoreRelUintptr(ptr *uintptr, val uintptr) 54 55 // 56 // Load 57 // 58 59 //go:noescape 60 func Load8(ptr *uint8) uint8 61 62 //go:noescape 63 func Load32(ptr *uint32) uint32 64 65 //go:noescape 66 func Load64(ptr *uint64) uint64 67 68 // NO go:noescape annotation; *ptr escapes if result escapes (#31525) 69 func LoadPointer(ptr unsafe.Pointer) unsafe.Pointer 70 71 // 72 // LoadAcq 73 // 74 75 //go:noescape 76 func LoadAcq32(addr *uint32) uint32 77 78 //go:noescape 79 func LoadAcq64(ptr *uint64) uint64 80 81 //go:noescape 82 func LoadAcqUintptr(ptr *uintptr) uintptr 83 84 // 85 // Swap 86 // 87 88 //go:noescape 89 func Swap32(ptr *uint32, new uint32) uint32 90 91 //go:noescape 92 func Swap64(ptr *uint64, new uint64) uint64 93 94 //go:noescape 95 func SwapUintptr(ptr *uintptr, new uintptr) uintptr 96 97 // 98 // Add 99 // 100 101 //go:noescape 102 func Add32(ptr *uint32, delta int32) uint32 103 104 //go:noescape 105 func Add64(ptr *uint64, delta int64) uint64 106 107 //go:noescape 108 func AddUintptr(ptr *uintptr, delta uintptr) uintptr 109 110 // 111 // bitwise 112 // 113 114 //go:noescape 115 func Or8(ptr *uint8, val uint8) 116 117 //go:noescape 118 func And8(ptr *uint8, val uint8) 119 120 //go:noescape 121 func Or32(ptr *uint32, val uint32) 122 123 //go:noescape 124 func And32(ptr *uint32, val uint32) 125 126 // 127 // Compare and swap 128 // 129 130 //go:noescape 131 func Cas64(ptr *uint64, old, new uint64) bool 132 133 // 134 // CasRel 135 // 136 137 //go:noescape 138 func CasRel32(ptr *uint32, old, new uint32) bool