Module Name: src
Committed By: skrll
Date: Wed Apr 21 07:31:38 UTC 2021
Modified Files:
src/common/lib/libc/arch/aarch64/atomic: Makefile.inc atomic_swap_16.S
atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S
Added Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_swap_acq_16.S
atomic_swap_acq_32.S atomic_swap_acq_64.S atomic_swap_acq_8.S
atomic_swap_acq_rel_16.S atomic_swap_acq_rel_32.S
atomic_swap_acq_rel_64.S atomic_swap_acq_rel_8.S
atomic_swap_rel_16.S atomic_swap_rel_32.S atomic_swap_rel_64.S
atomic_swap_rel_8.S
Log Message:
Provide some more operations that are part of compiler lse.S. This is
incomplete, but at least covers all the atomic_swap ops and allows the
aa64 kernel to link with gcc 10.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S
cvs rdiff -u -r0 -r1.1 \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/common/lib/libc/arch/aarch64/atomic/Makefile.inc
diff -u src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.1 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2
--- src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.1 Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/Makefile.inc Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:35 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2021/04/21 07:31:37 skrll Exp $
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|| ${LIB} == "rump")
@@ -11,6 +11,14 @@ SRCS.atomic+= atomic_${op}_${sz}.S
SRCS.atomic+= atomic_dec_32.S atomic_dec_64.S
SRCS.atomic+= atomic_inc_32.S atomic_inc_64.S
SRCS.atomic+= membar_ops.S
+#and cas nand or sub swap xor
+.for op in swap
+.for sz in 8 16 32 64
+.for ar in acq rel acq_rel
+SRCS.atomic+= atomic_${op}_${ar}_${sz}.S
+.endfor
+.endfor
+.endfor
#.for op in add and nand or sub xor
#SRCS.atomic+= sync_fetch_and_${op}_8.S
#.endfor
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.2 Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_swap_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_swap_16.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@ END(_atomic_swap_16)
ATOMIC_OP_ALIAS(atomic_swap_16,_atomic_swap_16)
ATOMIC_OP_ALIAS(atomic_swap_short,_atomic_swap_16)
ATOMIC_OP_ALIAS(atomic_swap_ushort,_atomic_swap_16)
+ATOMIC_OP_ALIAS(__aarch64_swp2_relax,_atomic_swap_16)
STRONG_ALIAS(__sync_lock_test_and_set_2,_atomic_swap_16)
STRONG_ALIAS(_atomic_swap_short,_atomic_swap_16)
STRONG_ALIAS(_atomic_swap_ushort,_atomic_swap_16)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.2 Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_swap_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_swap_32.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,6 +42,7 @@ END(_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
+ATOMIC_OP_ALIAS(__aarch64_swp4_relax,_atomic_swap_32)
STRONG_ALIAS(__sync_lock_test_and_set_4,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S:1.2 Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_swap_64.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_swap_64.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@ END(_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_64)
+ATOMIC_OP_ALIAS(__aarch64_swp8_relax,_atomic_swap_64)
STRONG_ALIAS(__sync_lock_test_and_set_8,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S:1.2 Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_swap_8.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_swap_8.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@ END(_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8)
+ATOMIC_OP_ALIAS(__aarch64_swp1_relax,_atomic_swap_8)
STRONG_ALIAS(__sync_lock_test_and_set_1,_atomic_swap_8)
STRONG_ALIAS(_atomic_swap_char,_atomic_swap_8)
STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_8)
Added files:
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_16.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_16)
+ mov x4, x0
+1: ldaxrh w0, [x4]
+ stxrh w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_16)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_16,_atomic_swap_acq_16)
+ATOMIC_OP_ALIAS(__aarch64_swp2_acq,_atomic_swap_acq_16)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_32.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_32)
+ mov x4, x0
+1: ldaxr w0, [x4]
+ stxr w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_32)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_32,_atomic_swap_acq_32)
+ATOMIC_OP_ALIAS(__aarch64_swp4_acq,_atomic_swap_acq_32)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_64.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_64)
+ mov x4, x0
+1: ldaxr x0, [x4]
+ stxr w3, x1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_64)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_64,_atomic_swap_acq_64)
+ATOMIC_OP_ALIAS(__aarch64_swp8_acq,_atomic_swap_acq_64)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_8.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_8)
+ mov x4, x0
+1: ldaxrb w0, [x4]
+ stxrb w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_8)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_8,_atomic_swap_acq_8)
+ATOMIC_OP_ALIAS(__aarch64_swp1_acq,_atomic_swap_acq_8)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_rel_16.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_rel_16)
+ mov x4, x0
+1: ldaxrh w0, [x4]
+ stlxrh w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_rel_16)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_rel_16,_atomic_swap_acq_rel_16)
+ATOMIC_OP_ALIAS(__aarch64_swp2_acq_rel,_atomic_swap_acq_rel_16)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_rel_32.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_rel_32)
+ mov x4, x0
+1: ldaxr w0, [x4]
+ stlxr w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_rel_32)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_rel_32,_atomic_swap_acq_rel_32)
+ATOMIC_OP_ALIAS(__aarch64_swp4_acq_rel,_atomic_swap_acq_rel_32)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_rel_64.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_rel_64)
+ mov x4, x0
+1: ldaxr x0, [x4]
+ stlxr w3, x1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_rel_64)
+
+ATOMIC_OP_ALIAS(atomic_swap_acq_rel_64,_atomic_swap_acq_rel_64)
+ATOMIC_OP_ALIAS(__aarch64_swp8_acq_rel,_atomic_swap_acq_rel_64)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_acq_rel_8.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_acq_rel_8)
+ mov x4, x0
+1: ldaxrb w0, [x4]
+ stlxrb w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_acq_rel_8)
+
+ATOMIC_OP_ALIAS(atomic_swap_rel_8,_atomic_swap_rel_8)
+ATOMIC_OP_ALIAS(__aarch64_swp1_rel,_atomic_swap_rel_8)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_rel_16.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_rel_16)
+ mov x4, x0
+1: ldxrh w0, [x4]
+ stlxrh w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_rel_16)
+
+ATOMIC_OP_ALIAS(atomic_swap_rel_16,_atomic_swap_rel_16)
+ATOMIC_OP_ALIAS(__aarch64_swp2_rel,_atomic_swap_rel_16)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_rel_32.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_rel_32)
+ mov x4, x0
+1: ldxr w0, [x4]
+ stlxr w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_rel_32)
+
+ATOMIC_OP_ALIAS(atomic_swap_rel_32,_atomic_swap_rel_32)
+ATOMIC_OP_ALIAS(__aarch64_swp4_rel,_atomic_swap_rel_32)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_rel_64.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_rel_64)
+ mov x4, x0
+1: ldxr x0, [x4]
+ stlxr w3, x1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_rel_64)
+
+ATOMIC_OP_ALIAS(atomic_swap_rel_64,_atomic_swap_rel_64)
+ATOMIC_OP_ALIAS(__aarch64_swp8_rel,_atomic_swap_rel_64)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S
diff -u /dev/null src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S:1.1
--- /dev/null Wed Apr 21 07:31:38 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S Wed Apr 21 07:31:37 2021
@@ -0,0 +1,44 @@
+/* $NetBSD: atomic_swap_rel_8.S,v 1.1 2021/04/21 07:31:37 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "atomic_op_asm.h"
+
+ENTRY_NP(_atomic_swap_rel_8)
+ mov x4, x0
+1: ldxrb w0, [x4]
+ stlxrb w3, w1, [x4]
+ cbnz w3, 2f
+ ret
+2: b 1b
+END(_atomic_swap_rel_8)
+
+ATOMIC_OP_ALIAS(atomic_swap_rel_8,_atomic_swap_rel_8)
+ATOMIC_OP_ALIAS(__aarch64_swp1_rel,_atomic_swap_rel_8)