github.com/primecitizens/pcz/std@v0.2.1/core/atomic/atomic_amd64.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2009 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 amd64
     9  
    10  package atomic
    11  
    12  import "unsafe"
    13  
    14  //
    15  // Store
    16  //
    17  
    18  //go:noescape
    19  func Store8(ptr *uint8, val uint8)
    20  
    21  //go:noescape
    22  func Store32(ptr *uint32, val uint32)
    23  
    24  //go:noescape
    25  func Store64(ptr *uint64, val uint64)
    26  
    27  // StorePointer performs *ptr = val atomically and without a write
    28  // barrier.
    29  //
    30  // NO go:noescape annotation; see atomic_pointer.go.
    31  func StorePointer(ptr unsafe.Pointer, val unsafe.Pointer)
    32  
    33  //
    34  // StoreRel
    35  //
    36  
    37  //go:noescape
    38  func StoreRel32(ptr *uint32, val uint32)
    39  
    40  //go:noescape
    41  func StoreRel64(ptr *uint64, val uint64)
    42  
    43  //go:noescape
    44  func StoreRelUintptr(ptr *uintptr, val uintptr)
    45  
    46  //
    47  // Load
    48  //
    49  
    50  //go:nosplit
    51  //go:noinline
    52  func Load8(ptr *uint8) uint8 { return *ptr }
    53  
    54  //go:nosplit
    55  //go:noinline
    56  func Load32(ptr *uint32) uint32 {
    57  	return *ptr
    58  }
    59  
    60  //go:nosplit
    61  //go:noinline
    62  func Load64(ptr *uint64) uint64 { return *ptr }
    63  
    64  //go:nosplit
    65  //go:noinline
    66  func LoadPointer(ptr unsafe.Pointer) unsafe.Pointer { return *(*unsafe.Pointer)(ptr) }
    67  
    68  //
    69  // LoadAcq
    70  //
    71  
    72  //go:nosplit
    73  //go:noinline
    74  func LoadAcq32(ptr *uint32) uint32 { return *ptr }
    75  
    76  //go:nosplit
    77  //go:noinline
    78  func LoadAcq64(ptr *uint64) uint64 { return *ptr }
    79  
    80  //go:nosplit
    81  //go:noinline
    82  func LoadAcqUintptr(ptr *uintptr) uintptr { return *ptr }
    83  
    84  //
    85  // bitwise
    86  //
    87  // NOTE: Do not add atomicxor8 (XOR is not idempotent).
    88  
    89  //go:noescape
    90  func And8(ptr *uint8, val uint8)
    91  
    92  //go:noescape
    93  func And32(ptr *uint32, val uint32)
    94  
    95  //go:noescape
    96  func Or8(ptr *uint8, val uint8)
    97  
    98  //go:noescape
    99  func Or32(ptr *uint32, val uint32)
   100  
   101  //
   102  // Swap
   103  //
   104  
   105  //go:noescape
   106  func Swap32(ptr *uint32, new uint32) uint32
   107  
   108  //go:noescape
   109  func Swap64(ptr *uint64, new uint64) uint64
   110  
   111  //go:noescape
   112  func SwapUintptr(ptr *uintptr, new uintptr) uintptr
   113  
   114  //
   115  // Add
   116  //
   117  
   118  //go:noescape
   119  func Add32(ptr *uint32, delta int32) uint32
   120  
   121  //go:noescape
   122  func Add64(ptr *uint64, delta int64) uint64
   123  
   124  //go:noescape
   125  func AddUintptr(ptr *uintptr, delta uintptr) uintptr
   126  
   127  //
   128  // Compare and swap
   129  //
   130  
   131  //go:noescape
   132  func Cas64(ptr *uint64, old, new uint64) bool
   133  
   134  //go:noescape
   135  func CasRel32(ptr *uint32, old, new uint32) bool