1 // Copyright 2012 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 #include "textflag.h" 6 7 // Darwin/ARM atomic operations. 8 9 TEXT CompareAndSwapInt32(SB),NOSPLIT,$0 10 B CompareAndSwapUint32(SB) 11 12 TEXT CompareAndSwapUint32(SB),NOSPLIT,$0 13 B armCompareAndSwapUint32(SB) 14 15 TEXT CompareAndSwapUintptr(SB),NOSPLIT,$0 16 B CompareAndSwapUint32(SB) 17 18 TEXT AddInt32(SB),NOSPLIT,$0 19 B AddUint32(SB) 20 21 TEXT AddUint32(SB),NOSPLIT,$0 22 B armAddUint32(SB) 23 24 TEXT AddUintptr(SB),NOSPLIT,$0 25 B AddUint32(SB) 26 27 TEXT SwapInt32(SB),NOSPLIT,$0 28 B SwapUint32(SB) 29 30 TEXT SwapUint32(SB),NOSPLIT,$0 31 B armSwapUint32(SB) 32 33 TEXT SwapUintptr(SB),NOSPLIT,$0 34 B SwapUint32(SB) 35 36 TEXT CompareAndSwapInt64(SB),NOSPLIT,$0 37 B CompareAndSwapUint64(SB) 38 39 TEXT CompareAndSwapUint64(SB),NOSPLIT,$-4 40 B armCompareAndSwapUint64(SB) 41 42 TEXT AddInt64(SB),NOSPLIT,$0 43 B addUint64(SB) 44 45 TEXT AddUint64(SB),NOSPLIT,$0 46 B addUint64(SB) 47 48 TEXT SwapInt64(SB),NOSPLIT,$0 49 B swapUint64(SB) 50 51 TEXT SwapUint64(SB),NOSPLIT,$0 52 B swapUint64(SB) 53 54 TEXT LoadInt32(SB),NOSPLIT,$0 55 B LoadUint32(SB) 56 57 TEXT LoadUint32(SB),NOSPLIT,$0-8 58 MOVW addr+0(FP), R1 59 load32loop: 60 LDREX (R1), R2 // loads R2 61 STREX R2, (R1), R0 // stores R2 62 CMP $0, R0 63 BNE load32loop 64 MOVW R2, val+4(FP) 65 RET 66 67 TEXT LoadInt64(SB),NOSPLIT,$0 68 B loadUint64(SB) 69 70 TEXT LoadUint64(SB),NOSPLIT,$0 71 B loadUint64(SB) 72 73 TEXT LoadUintptr(SB),NOSPLIT,$0 74 B LoadUint32(SB) 75 76 TEXT LoadPointer(SB),NOSPLIT,$0 77 B LoadUint32(SB) 78 79 TEXT StoreInt32(SB),NOSPLIT,$0 80 B StoreUint32(SB) 81 82 TEXT StoreUint32(SB),NOSPLIT,$0-8 83 MOVW addr+0(FP), R1 84 MOVW val+4(FP), R2 85 storeloop: 86 LDREX (R1), R4 // loads R4 87 STREX R2, (R1), R0 // stores R2 88 CMP $0, R0 89 BNE storeloop 90 RET 91 92 TEXT StoreInt64(SB),NOSPLIT,$0 93 B storeUint64(SB) 94 95 TEXT StoreUint64(SB),NOSPLIT,$0 96 B storeUint64(SB) 97 98 TEXT StoreUintptr(SB),NOSPLIT,$0 99 B StoreUint32(SB) 100