]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/internal/atomic/atomic_arm64.go
[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
[gostls13.git] / src / runtime / internal / atomic / atomic_arm64.go
1 // Copyright 2015 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 arm64
6
7 package atomic
8
9 import "unsafe"
10
11 //go:noescape
12 func Xadd(ptr *uint32, delta int32) uint32
13
14 //go:noescape
15 func Xadd64(ptr *uint64, delta int64) uint64
16
17 //go:noescape
18 func Xadduintptr(ptr *uintptr, delta uintptr) uintptr
19
20 //go:noescape
21 func Xchg(ptr *uint32, new uint32) uint32
22
23 //go:noescape
24 func Xchg64(ptr *uint64, new uint64) uint64
25
26 //go:noescape
27 func Xchguintptr(ptr *uintptr, new uintptr) uintptr
28
29 //go:noescape
30 func Load(ptr *uint32) uint32
31
32 //go:noescape
33 func Load64(ptr *uint64) uint64
34
35 //go:noescape
36 func Loadp(ptr unsafe.Pointer) unsafe.Pointer
37
38 //go:nosplit
39 func Or8(addr *uint8, v uint8) {
40         // TODO(dfc) implement this in asm.
41         // Align down to 4 bytes and use 32-bit CAS.
42         uaddr := uintptr(unsafe.Pointer(addr))
43         addr32 := (*uint32)(unsafe.Pointer(uaddr &^ 3))
44         word := uint32(v) << ((uaddr & 3) * 8) // little endian
45         for {
46                 old := *addr32
47                 if Cas(addr32, old, old|word) {
48                         return
49                 }
50         }
51 }
52
53 //go:nosplit
54 func And8(addr *uint8, v uint8) {
55         // TODO(dfc) 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) << ((uaddr & 3) * 8)    // little endian
60         mask := uint32(0xFF) << ((uaddr & 3) * 8) // little endian
61         word |= ^mask
62         for {
63                 old := *addr32
64                 if Cas(addr32, old, old&word) {
65                         return
66                 }
67         }
68 }
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)