github.com/sean-/go@v0.0.0-20151219100004-97f854cd7bb6/src/runtime/internal/atomic/atomic_amd64x.go (about) 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 atomic 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 Load(ptr *uint32) uint32 { 17 nop() 18 return *ptr 19 } 20 21 //go:nosplit 22 func Loadp(ptr unsafe.Pointer) unsafe.Pointer { 23 nop() 24 return *(*unsafe.Pointer)(ptr) 25 } 26 27 //go:nosplit 28 func Load64(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 //go:noescape 49 func Xchguintptr(ptr *uintptr, new uintptr) uintptr 50 51 //go:noescape 52 func And8(ptr *uint8, val uint8) 53 54 //go:noescape 55 func Or8(ptr *uint8, val uint8) 56 57 // NOTE: Do not add atomicxor8 (XOR is not idempotent). 58 59 //go:noescape 60 func Cas64(ptr *uint64, old, new uint64) bool 61 62 //go:noescape 63 func Store(ptr *uint32, val uint32) 64 65 //go:noescape 66 func Store64(ptr *uint64, val uint64) 67 68 // NO go:noescape annotation; see atomic_pointer.go. 69 func Storep1(ptr unsafe.Pointer, val unsafe.Pointer)