summaryrefslogtreecommitdiff
path: root/lib/libutils/ext/arch/arm/atomic_a64.S
blob: 429a80d15ad67745502da9211a5a57fe8519c38f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (c) 2015-2016, Linaro Limited
 */

#include <asm.S>


/* uint32_t atomic_inc32(uint32_t *v); */
FUNC atomic_inc32 , :
	ldaxr	w1, [x0]
	add	w1, w1, #1
	stxr	w2, w1, [x0]
	cmp	w2, #0
	bne	atomic_inc32
	mov	w0, w1
	ret
END_FUNC atomic_inc32

/* uint32_t atomic_dec32(uint32_t *v); */
FUNC atomic_dec32 , :
	ldaxr	w1, [x0]
	sub	w1, w1, #1
	stxr	w2, w1, [x0]
	cmp	w2, #0
	bne	atomic_dec32
	mov	w0, w1
	ret
END_FUNC atomic_dec32