1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2015-2016, Linaro Limited
4 */
5
6#include <asm.S>
7
8
9/* uint32_t atomic_inc32(uint32_t *v); */
10FUNC atomic_inc32 , :
11	ldaxr	w1, [x0]
12	add	w1, w1, #1
13	stxr	w2, w1, [x0]
14	cmp	w2, #0
15	bne	atomic_inc32
16	mov	w0, w1
17	ret
18END_FUNC atomic_inc32
19
20/* uint32_t atomic_dec32(uint32_t *v); */
21FUNC atomic_dec32 , :
22	ldaxr	w1, [x0]
23	sub	w1, w1, #1
24	stxr	w2, w1, [x0]
25	cmp	w2, #0
26	bne	atomic_dec32
27	mov	w0, w1
28	ret
29END_FUNC atomic_dec32
30
31BTI(emit_aarch64_feature_1_and     GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
32