blob: 56b89a5a0b038e52f88c6457daf7277f083a9abc [file] [log] [blame]
Michael Matloob67faca72015-11-02 14:09:24 -05001// 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;
14TEXT 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
18again:
19 LDAXRW (R0), R3
20 CMPW R1, R3
21 BNE ok
22 STLXRW R2, (R0), R3
23 CBNZ R3, again
24ok:
25 CSET EQ, R0
26 MOVB R0, ret+16(FP)
27 RET
28
29TEXT runtime∕internal∕atomic·Casuintptr(SB), NOSPLIT, $0-25
30 B runtime∕internal∕atomic·Cas64(SB)
31
Austin Clements8a064c62018-01-25 13:57:37 -050032TEXT runtime∕internal∕atomic·Loaduintptr(SB), NOSPLIT, $0-16
Michael Matloob67faca72015-11-02 14:09:24 -050033 B runtime∕internal∕atomic·Load64(SB)
34
Austin Clements8a064c62018-01-25 13:57:37 -050035TEXT runtime∕internal∕atomic·Loaduint(SB), NOSPLIT, $0-16
Michael Matloob67faca72015-11-02 14:09:24 -050036 B runtime∕internal∕atomic·Load64(SB)
37
38TEXT runtime∕internal∕atomic·Storeuintptr(SB), NOSPLIT, $0-16
39 B runtime∕internal∕atomic·Store64(SB)
40
Josh Bleecher Snyder40547692016-07-14 07:25:05 -070041TEXT runtime∕internal∕atomic·Xadduintptr(SB), NOSPLIT, $0-24
Michael Matloob67faca72015-11-02 14:09:24 -050042 B runtime∕internal∕atomic·Xadd64(SB)
43
44TEXT runtime∕internal∕atomic·Loadint64(SB), NOSPLIT, $0-16
45 B runtime∕internal∕atomic·Load64(SB)
46
Josh Bleecher Snyder40547692016-07-14 07:25:05 -070047TEXT runtime∕internal∕atomic·Xaddint64(SB), NOSPLIT, $0-24
Michael Matloob67faca72015-11-02 14:09:24 -050048 B runtime∕internal∕atomic·Xadd64(SB)
49
Josh Bleecher Snyder71ab9fa2016-07-11 16:05:57 -070050// bool Casp1(void **val, void *old, void *new)
Michael Matloob67faca72015-11-02 14:09:24 -050051// Atomically:
52// if(*val == old){
53// *val = new;
54// return 1;
55// } else
56// return 0;
57TEXT runtime∕internal∕atomic·Casp1(SB), NOSPLIT, $0-25
58 B runtime∕internal∕atomic·Cas64(SB)