fix atomic_sub_*(). it was (delta - *ptr), should be (*ptr - delta).

changing shared macro doesn't effect other atomic_ops because
(*ptr [+|^] delta) and (delta [+|^] *ptr) have same result.

atomic_sub_*() haven't used because non standard API?
This commit is contained in:
ryo 2019-02-06 05:33:14 +00:00
parent bb063a3750
commit 706088913a
1 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: atomic_op_asm.h,v 1.1 2014/08/10 05:47:35 matt Exp $ */
/* $NetBSD: atomic_op_asm.h,v 1.2 2019/02/06 05:33:14 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
ENTRY_NP(_atomic_##OP##_8) ;\
mov x4, x0 ;\
1: ldxrb w0, [x4] /* load old value */ ;\
INSN w2, w1, w0 /* calculate new value */ ;\
INSN w2, w0, w1 /* calculate new value */ ;\
stxrb w3, w2, [x4] /* try to store */ ;\
cbnz w3, 1b /* succeed? no, try again */ ;\
dmb st ;\
@ -49,7 +49,7 @@ END(_atomic_##OP##_8)
ENTRY_NP(_atomic_##OP##_8_nv) ;\
mov x4, x0 /* need r0 for return value */ ;\
1: ldxrb w0, [x4] /* load old value */ ;\
INSN w2, w1, w0 /* calc new (return) value */ ;\
INSN w2, w0, w1 /* calc new (return) value */ ;\
stxrb w3, w2, [x4] /* try to store */ ;\
cbnz w3, 1b /* succeed? no, try again */ ;\
dmb st ;\
@ -60,7 +60,7 @@ END(_atomic_##OP##_8_nv)
ENTRY_NP(_atomic_##OP##_16) ;\
mov x4, x0 ;\
1: ldxrh w0, [x4] /* load old value */ ;\
INSN w2, w1, w0 /* calculate new value */ ;\
INSN w2, w0, w1 /* calculate new value */ ;\
stxrh w3, w2, [x4] /* try to store */ ;\
cbnz w3, 1b /* succeed? no, try again */ ;\
dmb st ;\
@ -71,7 +71,7 @@ END(_atomic_##OP##_16)
ENTRY_NP(_atomic_##OP##_16_nv) ;\
mov x4, x0 /* need r0 for return value */ ;\
1: ldxrh w0, [x4] /* load old value */ ;\
INSN w2, w1, w0 /* calc new (return) value */ ;\
INSN w2, w0, w1 /* calc new (return) value */ ;\
stxrh w3, w2, [x4] /* try to store */ ;\
cbnz w3, 1b /* succeed? no, try again */ ;\
dmb st ;\
@ -82,7 +82,7 @@ END(_atomic_##OP##_16_nv)
ENTRY_NP(_atomic_##OP##_32) ;\
mov x4, x0 ;\
1: ldxr w0, [x4] /* load old value */ ;\
INSN w2, w1, w0 /* calculate new value */ ;\
INSN w2, w0, w1 /* calculate new value */ ;\
stxr w3, w2, [x4] /* try to store */ ;\
cbnz w3, 1b /* succeed? no, try again */ ;\
dmb st ;\
@ -104,7 +104,7 @@ END(_atomic_##OP##_32_nv)
ENTRY_NP(_atomic_##OP##_64) ;\
mov x4, x0 ;\
1: ldxr x0, [x4] /* load old value */ ;\
INSN x2, x1, x0 /* calculate new value */ ;\
INSN x2, x0, x1 /* calculate new value */ ;\
stxr w3, x2, [x4] /* try to store */ ;\
cbnz w3, 1b /* succeed? no, try again */ ;\
dmb st ;\