github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/atomicbitops/atomicbitops_arm64.s (about) 1 // Copyright 2019 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build arm64 16 17 #include "textflag.h" 18 19 TEXT ·AndUint32(SB),$0-12 20 MOVD ptr+0(FP), R0 21 MOVW val+8(FP), R1 22 again: 23 LDAXRW (R0), R2 24 ANDW R1, R2 25 STLXRW R2, (R0), R3 26 CBNZ R3, again 27 RET 28 29 TEXT ·OrUint32(SB),$0-12 30 MOVD ptr+0(FP), R0 31 MOVW val+8(FP), R1 32 again: 33 LDAXRW (R0), R2 34 ORRW R1, R2 35 STLXRW R2, (R0), R3 36 CBNZ R3, again 37 RET 38 39 TEXT ·XorUint32(SB),$0-12 40 MOVD ptr+0(FP), R0 41 MOVW val+8(FP), R1 42 again: 43 LDAXRW (R0), R2 44 EORW R1, R2 45 STLXRW R2, (R0), R3 46 CBNZ R3, again 47 RET 48 49 TEXT ·CompareAndSwapUint32(SB),$0-20 50 MOVD addr+0(FP), R0 51 MOVW old+8(FP), R1 52 MOVW new+12(FP), R2 53 again: 54 LDAXRW (R0), R3 55 CMPW R1, R3 56 BNE done 57 STLXRW R2, (R0), R4 58 CBNZ R4, again 59 done: 60 MOVW R3, prev+16(FP) 61 RET 62 63 TEXT ·AndUint64(SB),$0-16 64 MOVD ptr+0(FP), R0 65 MOVD val+8(FP), R1 66 again: 67 LDAXR (R0), R2 68 AND R1, R2 69 STLXR R2, (R0), R3 70 CBNZ R3, again 71 RET 72 73 TEXT ·OrUint64(SB),$0-16 74 MOVD ptr+0(FP), R0 75 MOVD val+8(FP), R1 76 again: 77 LDAXR (R0), R2 78 ORR R1, R2 79 STLXR R2, (R0), R3 80 CBNZ R3, again 81 RET 82 83 TEXT ·XorUint64(SB),$0-16 84 MOVD ptr+0(FP), R0 85 MOVD val+8(FP), R1 86 again: 87 LDAXR (R0), R2 88 EOR R1, R2 89 STLXR R2, (R0), R3 90 CBNZ R3, again 91 RET 92 93 TEXT ·CompareAndSwapUint64(SB),$0-32 94 MOVD addr+0(FP), R0 95 MOVD old+8(FP), R1 96 MOVD new+16(FP), R2 97 again: 98 LDAXR (R0), R3 99 CMP R1, R3 100 BNE done 101 STLXR R2, (R0), R4 102 CBNZ R4, again 103 done: 104 MOVD R3, prev+24(FP) 105 RET