| 1 |
// Copyright 2023 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build !(386 || arm || mips || mipsle) |
| 6 |
|
| 7 |
package atomic |
| 8 |
|
| 9 |
// SwapInt64 atomically stores new into *addr and returns the previous *addr value. |
| 10 |
// Consider using the more ergonomic and less error-prone [Int64.Swap] instead |
| 11 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 12 |
// |
| 13 |
//go:noescape |
| 14 |
func SwapInt64(addr *int64, new int64) (old int64) |
| 15 |
|
| 16 |
// SwapUint64 atomically stores new into *addr and returns the previous *addr value. |
| 17 |
// Consider using the more ergonomic and less error-prone [Uint64.Swap] instead |
| 18 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 19 |
// |
| 20 |
//go:noescape |
| 21 |
func SwapUint64(addr *uint64, new uint64) (old uint64) |
| 22 |
|
| 23 |
// CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value. |
| 24 |
// Consider using the more ergonomic and less error-prone [Int64.CompareAndSwap] instead |
| 25 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 26 |
// |
| 27 |
//go:noescape |
| 28 |
func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool) |
| 29 |
|
| 30 |
// CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value. |
| 31 |
// Consider using the more ergonomic and less error-prone [Uint64.CompareAndSwap] instead |
| 32 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 33 |
// |
| 34 |
//go:noescape |
| 35 |
func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool) |
| 36 |
|
| 37 |
// AddInt64 atomically adds delta to *addr and returns the new value. |
| 38 |
// Consider using the more ergonomic and less error-prone [Int64.Add] instead |
| 39 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 40 |
// |
| 41 |
//go:noescape |
| 42 |
func AddInt64(addr *int64, delta int64) (new int64) |
| 43 |
|
| 44 |
// AddUint64 atomically adds delta to *addr and returns the new value. |
| 45 |
// To subtract a signed positive constant value c from x, do AddUint64(&x, ^uint64(c-1)). |
| 46 |
// In particular, to decrement x, do AddUint64(&x, ^uint64(0)). |
| 47 |
// Consider using the more ergonomic and less error-prone [Uint64.Add] instead |
| 48 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 49 |
// |
| 50 |
//go:noescape |
| 51 |
func AddUint64(addr *uint64, delta uint64) (new uint64) |
| 52 |
|
| 53 |
// AndInt64 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask |
| 54 |
// and returns the old value. |
| 55 |
// Consider using the more ergonomic and less error-prone [Int64.And] instead. |
| 56 |
// |
| 57 |
//go:noescape |
| 58 |
func AndInt64(addr *int64, mask int64) (old int64) |
| 59 |
|
| 60 |
// AndUint64 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask |
| 61 |
// and returns the old. |
| 62 |
// Consider using the more ergonomic and less error-prone [Uint64.And] instead. |
| 63 |
// |
| 64 |
//go:noescape |
| 65 |
func AndUint64(addr *uint64, mask uint64) (old uint64) |
| 66 |
|
| 67 |
// OrInt64 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask |
| 68 |
// and returns the old value. |
| 69 |
// Consider using the more ergonomic and less error-prone [Int64.Or] instead. |
| 70 |
// |
| 71 |
//go:noescape |
| 72 |
func OrInt64(addr *int64, mask int64) (old int64) |
| 73 |
|
| 74 |
// OrUint64 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask |
| 75 |
// and returns the old value. |
| 76 |
// Consider using the more ergonomic and less error-prone [Uint64.Or] instead. |
| 77 |
// |
| 78 |
//go:noescape |
| 79 |
func OrUint64(addr *uint64, mask uint64) (old uint64) |
| 80 |
|
| 81 |
// LoadInt64 atomically loads *addr. |
| 82 |
// Consider using the more ergonomic and less error-prone [Int64.Load] instead |
| 83 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 84 |
// |
| 85 |
//go:noescape |
| 86 |
func LoadInt64(addr *int64) (val int64) |
| 87 |
|
| 88 |
// LoadUint64 atomically loads *addr. |
| 89 |
// Consider using the more ergonomic and less error-prone [Uint64.Load] instead |
| 90 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 91 |
// |
| 92 |
//go:noescape |
| 93 |
func LoadUint64(addr *uint64) (val uint64) |
| 94 |
|
| 95 |
// StoreInt64 atomically stores val into *addr. |
| 96 |
// Consider using the more ergonomic and less error-prone [Int64.Store] instead |
| 97 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 98 |
// |
| 99 |
//go:noescape |
| 100 |
func StoreInt64(addr *int64, val int64) |
| 101 |
|
| 102 |
// StoreUint64 atomically stores val into *addr. |
| 103 |
// Consider using the more ergonomic and less error-prone [Uint64.Store] instead |
| 104 |
// (particularly if you target 32-bit platforms; see the bugs section). |
| 105 |
// |
| 106 |
//go:noescape |
| 107 |
func StoreUint64(addr *uint64, val uint64) |