Michael Matloob | 67faca7 | 2015-11-02 14:09:24 -0500 | [diff] [blame] | 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 Cas(uint32 *ptr, uint32 old, uint32 new) |
| 8 | // Atomically: |
| 9 | // if(*val == old){ |
| 10 | // *val = new; |
| 11 | // return 1; |
| 12 | // } else |
| 13 | // return 0; |
| 14 | TEXT runtime∕internal∕atomic·Cas(SB), NOSPLIT, $0-17 |
| 15 | MOVD ptr+0(FP), R0 |
| 16 | MOVW old+8(FP), R1 |
| 17 | MOVW new+12(FP), R2 |
| 18 | again: |
| 19 | LDAXRW (R0), R3 |
| 20 | CMPW R1, R3 |
| 21 | BNE ok |
| 22 | STLXRW R2, (R0), R3 |
| 23 | CBNZ R3, again |
| 24 | ok: |
| 25 | CSET EQ, R0 |
| 26 | MOVB R0, ret+16(FP) |
| 27 | RET |
| 28 | |
| 29 | TEXT runtime∕internal∕atomic·Casuintptr(SB), NOSPLIT, $0-25 |
| 30 | B runtime∕internal∕atomic·Cas64(SB) |
| 31 | |
Austin Clements | 8a064c6 | 2018-01-25 13:57:37 -0500 | [diff] [blame] | 32 | TEXT runtime∕internal∕atomic·Loaduintptr(SB), NOSPLIT, $0-16 |
Michael Matloob | 67faca7 | 2015-11-02 14:09:24 -0500 | [diff] [blame] | 33 | B runtime∕internal∕atomic·Load64(SB) |
| 34 | |
Austin Clements | 8a064c6 | 2018-01-25 13:57:37 -0500 | [diff] [blame] | 35 | TEXT runtime∕internal∕atomic·Loaduint(SB), NOSPLIT, $0-16 |
Michael Matloob | 67faca7 | 2015-11-02 14:09:24 -0500 | [diff] [blame] | 36 | B runtime∕internal∕atomic·Load64(SB) |
| 37 | |
| 38 | TEXT runtime∕internal∕atomic·Storeuintptr(SB), NOSPLIT, $0-16 |
| 39 | B runtime∕internal∕atomic·Store64(SB) |
| 40 | |
Josh Bleecher Snyder | 4054769 | 2016-07-14 07:25:05 -0700 | [diff] [blame] | 41 | TEXT runtime∕internal∕atomic·Xadduintptr(SB), NOSPLIT, $0-24 |
Michael Matloob | 67faca7 | 2015-11-02 14:09:24 -0500 | [diff] [blame] | 42 | B runtime∕internal∕atomic·Xadd64(SB) |
| 43 | |
| 44 | TEXT runtime∕internal∕atomic·Loadint64(SB), NOSPLIT, $0-16 |
| 45 | B runtime∕internal∕atomic·Load64(SB) |
| 46 | |
Josh Bleecher Snyder | 4054769 | 2016-07-14 07:25:05 -0700 | [diff] [blame] | 47 | TEXT runtime∕internal∕atomic·Xaddint64(SB), NOSPLIT, $0-24 |
Michael Matloob | 67faca7 | 2015-11-02 14:09:24 -0500 | [diff] [blame] | 48 | B runtime∕internal∕atomic·Xadd64(SB) |
| 49 | |
Josh Bleecher Snyder | 71ab9fa | 2016-07-11 16:05:57 -0700 | [diff] [blame] | 50 | // bool Casp1(void **val, void *old, void *new) |
Michael Matloob | 67faca7 | 2015-11-02 14:09:24 -0500 | [diff] [blame] | 51 | // Atomically: |
| 52 | // if(*val == old){ |
| 53 | // *val = new; |
| 54 | // return 1; |
| 55 | // } else |
| 56 | // return 0; |
| 57 | TEXT runtime∕internal∕atomic·Casp1(SB), NOSPLIT, $0-25 |
| 58 | B runtime∕internal∕atomic·Cas64(SB) |