Home | History | Annotate | Download | only in runtime
      1 // Copyright 2009 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 // +build amd64 amd64p32
      6 
      7 package runtime
      8 
      9 import "unsafe"
     10 
     11 // The calls to nop are to keep these functions from being inlined.
     12 // If they are inlined we have no guarantee that later rewrites of the
     13 // code by optimizers will preserve the relative order of memory accesses.
     14 
     15 //go:nosplit
     16 func atomicload(ptr *uint32) uint32 {
     17 	nop()
     18 	return *ptr
     19 }
     20 
     21 //go:nosplit
     22 func atomicloadp(ptr unsafe.Pointer) unsafe.Pointer {
     23 	nop()
     24 	return *(*unsafe.Pointer)(ptr)
     25 }
     26 
     27 //go:nosplit
     28 func atomicload64(ptr *uint64) uint64 {
     29 	nop()
     30 	return *ptr
     31 }
     32 
     33 //go:noescape
     34 func xadd(ptr *uint32, delta int32) uint32
     35 
     36 //go:noescape
     37 func xadd64(ptr *uint64, delta int64) uint64
     38 
     39 //go:noescape
     40 func xadduintptr(ptr *uintptr, delta uintptr) uintptr
     41 
     42 //go:noescape
     43 func xchg(ptr *uint32, new uint32) uint32
     44 
     45 //go:noescape
     46 func xchg64(ptr *uint64, new uint64) uint64
     47 
     48 // NO go:noescape annotation; see atomic_pointer.go.
     49 func xchgp1(ptr unsafe.Pointer, new unsafe.Pointer) unsafe.Pointer
     50 
     51 //go:noescape
     52 func xchguintptr(ptr *uintptr, new uintptr) uintptr
     53 
     54 //go:noescape
     55 func atomicand8(ptr *uint8, val uint8)
     56 
     57 //go:noescape
     58 func atomicor8(ptr *uint8, val uint8)
     59 
     60 // NOTE: Do not add atomicxor8 (XOR is not idempotent).
     61 
     62 //go:noescape
     63 func cas64(ptr *uint64, old, new uint64) bool
     64 
     65 //go:noescape
     66 func atomicstore(ptr *uint32, val uint32)
     67 
     68 //go:noescape
     69 func atomicstore64(ptr *uint64, val uint64)
     70 
     71 // NO go:noescape annotation; see atomic_pointer.go.
     72 func atomicstorep1(ptr unsafe.Pointer, val unsafe.Pointer)
     73