github.com/hlts2/go@v0.0.0-20170904000733-812b34efaed8/src/runtime/internal/atomic/asm_arm.s (about) 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 #include "textflag.h" 6 7 // bool armcas(int32 *val, int32 old, int32 new) 8 // Atomically: 9 // if(*val == old){ 10 // *val = new; 11 // return 1; 12 // }else 13 // return 0; 14 // 15 // To implement runtime∕internal∕atomic·cas in sys_$GOOS_arm.s 16 // using the native instructions, use: 17 // 18 // TEXT runtime∕internal∕atomic·cas(SB),NOSPLIT,$0 19 // B runtime∕internal∕atomic·armcas(SB) 20 // 21 TEXT runtime∕internal∕atomic·armcas(SB),NOSPLIT,$0-13 22 MOVW ptr+0(FP), R1 23 MOVW old+4(FP), R2 24 MOVW new+8(FP), R3 25 casl: 26 LDREX (R1), R0 27 CMP R0, R2 28 BNE casfail 29 30 MOVB runtime·goarm(SB), R11 31 CMP $7, R11 32 BLT 2(PC) 33 WORD $0xf57ff05a // dmb ishst 34 35 STREX R3, (R1), R0 36 CMP $0, R0 37 BNE casl 38 MOVW $1, R0 39 40 MOVB runtime·goarm(SB), R11 41 CMP $7, R11 42 BLT 2(PC) 43 WORD $0xf57ff05b // dmb ish 44 45 MOVB R0, ret+12(FP) 46 RET 47 casfail: 48 MOVW $0, R0 49 MOVB R0, ret+12(FP) 50 RET 51 52 TEXT runtime∕internal∕atomic·Casuintptr(SB),NOSPLIT,$0-13 53 B runtime∕internal∕atomic·Cas(SB) 54 55 TEXT runtime∕internal∕atomic·Loaduintptr(SB),NOSPLIT,$0-8 56 B runtime∕internal∕atomic·Load(SB) 57 58 TEXT runtime∕internal∕atomic·Loaduint(SB),NOSPLIT,$0-8 59 B runtime∕internal∕atomic·Load(SB) 60 61 TEXT runtime∕internal∕atomic·Storeuintptr(SB),NOSPLIT,$0-8 62 B runtime∕internal∕atomic·Store(SB) 63 64 TEXT runtime∕internal∕atomic·Xadduintptr(SB),NOSPLIT,$0-12 65 B runtime∕internal∕atomic·Xadd(SB) 66 67 TEXT runtime∕internal∕atomic·Loadint64(SB),NOSPLIT,$0-12 68 B runtime∕internal∕atomic·Load64(SB) 69 70 TEXT runtime∕internal∕atomic·Xaddint64(SB),NOSPLIT,$0-20 71 B runtime∕internal∕atomic·Xadd64(SB)