github.com/4ad/go@v0.0.0-20161219182952-69a12818b605/src/runtime/internal/atomic/atomic_sparc64.go (about) 1 // Copyright 2016 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 package atomic 6 7 import "unsafe" 8 9 //go:noescape 10 func Xadd(ptr *uint32, delta int32) uint32 11 12 //go:noescape 13 func Xadd64(ptr *uint64, delta int64) uint64 14 15 //go:noescape 16 func Xadduintptr(ptr *uintptr, delta uintptr) uintptr 17 18 //go:noescape 19 func Xchg(ptr *uint32, new uint32) uint32 20 21 //go:noescape 22 func Xchg64(ptr *uint64, new uint64) uint64 23 24 //go:noescape 25 func Xchguintptr(ptr *uintptr, new uintptr) uintptr 26 27 //go:noescape 28 func Load(ptr *uint32) uint32 29 30 //go:noescape 31 func Load64(ptr *uint64) uint64 32 33 //go:noescape 34 func Loadp(ptr unsafe.Pointer) unsafe.Pointer 35 36 //go:nosplit 37 func And8(addr *uint8, v uint8) { 38 // TODO(aram) implement this in asm. 39 // Align down to 4 bytes and use 32-bit CAS. 40 uaddr := uintptr(unsafe.Pointer(addr)) 41 addr32 := (*uint32)(unsafe.Pointer(uaddr &^ 3)) 42 word := (uint32(v) << 24) >> ((uaddr & 3) * 8) // big endian 43 mask := (uint32(0xFF) << 24) >> ((uaddr & 3) * 8) // big endian 44 word |= ^mask 45 for { 46 old := *addr32 47 if Cas(addr32, old, old&word) { 48 return 49 } 50 } 51 } 52 53 //go:nosplit 54 func Or8(addr *uint8, v uint8) { 55 // TODO(aram) implement this in asm. 56 // Align down to 4 bytes and use 32-bit CAS. 57 uaddr := uintptr(unsafe.Pointer(addr)) 58 addr32 := (*uint32)(unsafe.Pointer(uaddr &^ 3)) 59 word := (uint32(v) << 24) >> ((uaddr & 3) * 8) // big endian 60 for { 61 old := *addr32 62 if Cas(addr32, old, old|word) { 63 return 64 } 65 } 66 } 67 68 // NOTE: Do not add atomicxor8 (XOR is not idempotent). 69 70 //go:noescape 71 func Cas64(ptr *uint64, old, new uint64) bool 72 73 //go:noescape 74 func Store(ptr *uint32, val uint32) 75 76 //go:noescape 77 func Store64(ptr *uint64, val uint64) 78 79 // NO go:noescape annotation; see atomic_pointer.go. 80 func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer)