github.com/aloncn/graphics-go@v0.0.1/src/runtime/internal/atomic/atomic_386.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 386 6 7 package atomic 8 9 import "unsafe" 10 11 //go:nosplit 12 //go:noinline 13 func Load(ptr *uint32) uint32 { 14 return *ptr 15 } 16 17 //go:nosplit 18 //go:noinline 19 func Loadp(ptr unsafe.Pointer) unsafe.Pointer { 20 return *(*unsafe.Pointer)(ptr) 21 } 22 23 //go:nosplit 24 func Xadd64(ptr *uint64, delta int64) uint64 { 25 for { 26 old := *ptr 27 if Cas64(ptr, old, old+uint64(delta)) { 28 return old + uint64(delta) 29 } 30 } 31 } 32 33 //go:noescape 34 func Xadduintptr(ptr *uintptr, delta uintptr) uintptr 35 36 //go:nosplit 37 func Xchg64(ptr *uint64, new uint64) uint64 { 38 for { 39 old := *ptr 40 if Cas64(ptr, old, new) { 41 return old 42 } 43 } 44 } 45 46 //go:noescape 47 func Xadd(ptr *uint32, delta int32) uint32 48 49 //go:noescape 50 func Xchg(ptr *uint32, new uint32) uint32 51 52 //go:noescape 53 func Xchguintptr(ptr *uintptr, new uintptr) uintptr 54 55 //go:noescape 56 func Load64(ptr *uint64) uint64 57 58 //go:noescape 59 func And8(ptr *uint8, val uint8) 60 61 //go:noescape 62 func Or8(ptr *uint8, val uint8) 63 64 // NOTE: Do not add atomicxor8 (XOR is not idempotent). 65 66 //go:noescape 67 func Cas64(ptr *uint64, old, new uint64) bool 68 69 //go:noescape 70 func Store(ptr *uint32, val uint32) 71 72 //go:noescape 73 func Store64(ptr *uint64, val uint64) 74 75 // NO go:noescape annotation; see atomic_pointer.go. 76 func Storep1(ptr unsafe.Pointer, val unsafe.Pointer)