Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libc/arch/aarch64/atomic Fix the logic operation ...
details: https://anonhg.NetBSD.org/src/rev/870e4d4cee73
branches: trunk
changeset: 984340:870e4d4cee73
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Jul 04 06:55:47 2021 +0000
description:
Fix the logic operation for atomic_nand_{8,16,32,64}
>From the gcc docs the operations are as follows
{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand
{ tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand
yes, this is really rather strange.
diffstat:
common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S | 21 +++++++++++++------
common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S | 19 ++++++++++++-----
common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S | 21 +++++++++++++------
common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S | 20 ++++++++++++------
4 files changed, 54 insertions(+), 27 deletions(-)
diffs (182 lines):
diff -r ea8505dc5001 -r 870e4d4cee73 common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S
--- a/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S Sun Jul 04 05:49:20 2021 +0000
+++ b/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S Sun Jul 04 06:55:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_nand_16.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
#include "atomic_op_asm.h"
+/*
+ * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand
+ */
ENTRY_NP(_atomic_nand_16)
mov x4, x0
-1: ldxrh w0, [x4] /* load old value (to be returned) */
- mvn w3, w0 /* complement source */
- and w3, w3, w1 /* calculate new value */
+1: ldxrh w0, [x4] /* load old value (*ptr) */
+ and w3, w0, w1 /* w3 = (*ptr & value) */
+ mvn w3, w3 /* w3 = ~(*pte & value) */
stxrh w2, w3, [x4] /* try to store */
cbnz w2, 2f /* succeed? no, try again */
ret /* return old value */
@@ -47,11 +50,15 @@
STRONG_ALIAS(__sync_fetch_and_nand_2,_atomic_nand_16)
STRONG_ALIAS(_atomic_nand_ushort,_atomic_nand_16)
+
+/*
+ * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand
+ */
ENTRY_NP(_atomic_nand_16_nv)
mov x4, x0 /* need r0 for return value */
-1: ldxrh w0, [x4] /* load old value */
- mvn w0, w0 /* complement source */
- and w0, w0, w1 /* calculate new value (return value) */
+1: ldxrh w0, [x4] /* load old value (*ptr) */
+ and w0, w0, w1 /* w0 = (*ptr & value) */
+ mvn w0, w0 /* w0 = ~(*pte & value), return value */
stxrh w2, w0, [x4] /* try to store */
cbnz w2, 2f /* succeed? no, try again? */
ret /* return new value */
diff -r ea8505dc5001 -r 870e4d4cee73 common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S
--- a/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S Sun Jul 04 05:49:20 2021 +0000
+++ b/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S Sun Jul 04 06:55:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_nand_32.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
#include "atomic_op_asm.h"
+/*
+ * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand
+ */
ENTRY_NP(_atomic_nand_32)
mov x4, x0
1: ldxr w0, [x4] /* load old value (to be returned) */
- mvn w3, w0 /* complement source */
- and w3, w3, w1 /* calculate new value */
+ and w3, w0, w1 /* w3 = (*ptr & value) */
+ mvn w3, w3 /* x3 = ~(*pte & value) */
stxr w2, w3, [x4] /* try to store */
cbnz w2, 2f /* succeed? no, try again */
ret /* return old value */
@@ -47,11 +50,15 @@
STRONG_ALIAS(__sync_fetch_and_nand_4,_atomic_nand_32)
STRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32)
+
+/*
+ * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand
+ */
ENTRY_NP(_atomic_nand_32_nv)
mov x4, x0 /* need r0 for return value */
-1: ldxr w0, [x4] /* load old value */
- mvn w0, w0 /* complement source */
- and w0, w0, w1 /* calculate new value (return value) */
+1: ldxr w0, [x4] /* load old value (*ptr) */
+ and w0, w0, w1 /* x0 = (*ptr & value) */
+ mvn w0, w0 /* x0 = ~(*pte & value), return value */
stxr w2, w0, [x4] /* try to store */
cbnz w2, 2f /* succeed? no, try again? */
ret /* return new value */
diff -r ea8505dc5001 -r 870e4d4cee73 common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S
--- a/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S Sun Jul 04 05:49:20 2021 +0000
+++ b/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S Sun Jul 04 06:55:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_64.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_nand_64.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
#include "atomic_op_asm.h"
+/*
+ * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand
+ */
ENTRY_NP(_atomic_nand_64)
mov x4, x0
-1: ldxr x0, [x4] /* load old value (to be returned) */
- mvn x2, x0 /* complement source */
- and x2, x2, x1 /* calculate new value */
+1: ldxr x0, [x4] /* load old value (*ptr) */
+ and x2, x0, x1 /* x2 = (*ptr & value) */
+ mvn x2, x2 /* x2 = ~(*pte & value) */
stxr w3, x2, [x4] /* try to store */
cbnz w3, 2f /* succeed? no, try again */
ret /* return old value */
@@ -47,11 +50,15 @@
STRONG_ALIAS(__sync_fetch_and_nand_8,_atomic_nand_64)
STRONG_ALIAS(_atomic_nand_ulong,_atomic_nand_64)
+
+/*
+ * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand
+ */
ENTRY_NP(_atomic_nand_64_nv)
mov x4, x0 /* need r0 for return value */
-1: ldxr x0, [x4] /* load old value */
- mvn x0, x0 /* complement source */
- and x0, x0, x1 /* calculate new value (return value) */
+1: ldxr x0, [x4] /* load old value (*ptr) */
+ and x0, x0, x1 /* x0 = (*ptr & value) */
+ mvn x0, x0 /* x0 = ~(*pte & value), return value */
stxr w3, x0, [x4] /* try to store */
cbnz w3, 2f /* succeed? no, try again? */
ret /* return new value */
diff -r ea8505dc5001 -r 870e4d4cee73 common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S
--- a/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S Sun Jul 04 05:49:20 2021 +0000
+++ b/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S Sun Jul 04 06:55:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_8.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_nand_8.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
#include "atomic_op_asm.h"
+/*
+ * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand
+ */
ENTRY_NP(_atomic_nand_8)
mov x4, x0
-1: ldxrb w0, [x4] /* load old value (to be returned) */
- mvn w3, w0 /* complement source */
- and w3, w3, w1 /* calculate new value */
+1: ldxrb w0, [x4] /* load old value (*ptr) */
+ and w3, w0, w1 /* w3 = (*ptr & value) */
+ mvn w3, w3 /* w3 = ~(*pte & value) */
stxrb w2, w3, [x4] /* try to store */
cbnz w2, 2f /* succeed? no, try again */
ret /* return old value */
@@ -47,11 +50,14 @@
STRONG_ALIAS(__sync_fetch_and_nand_1,_atomic_nand_8)
STRONG_ALIAS(_atomic_nand_uchar,_atomic_nand_8)
+/*
+ * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; } // nand
+ */
ENTRY_NP(_atomic_nand_8_nv)
mov x4, x0 /* need r0 for return value */
-1: ldxrb w0, [x4] /* load old value */
- mvn w0, w0 /* complement source */
- and w0, w0, w1 /* calculate new value (return value) */
+1: ldxrb w0, [x4] /* load old value (*ptr) */
+ and w0, w0, w1 /* w0 = (*ptr & value) */
+ mvn w0, w0 /* w0 = ~(*pte & value), return value */
stxrb w2, w0, [x4] /* try to store */
cbnz w2, 2f /* succeed? no, try again? */
ret /* return new value */
Home |
Main Index |
Thread Index |
Old Index