Module Name:    src
Committed By:   riastradh
Date:           Fri Aug 12 11:21:44 UTC 2022

Modified Files:
        src/tests/lib/libc/membar: t_spinlock.c

Log Message:
membar(3): Fix t_spinlock for machines with hash-locked atomics.

Regular stores don't participate in the hash-locking scheme, so use
atomic_swap instead of a regular store here.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/membar/t_spinlock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/membar/t_spinlock.c
diff -u src/tests/lib/libc/membar/t_spinlock.c:1.3 src/tests/lib/libc/membar/t_spinlock.c:1.4
--- src/tests/lib/libc/membar/t_spinlock.c:1.3	Sun Apr 10 11:36:32 2022
+++ src/tests/lib/libc/membar/t_spinlock.c	Fri Aug 12 11:21:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_spinlock.c,v 1.3 2022/04/10 11:36:32 riastradh Exp $	*/
+/*	$NetBSD: t_spinlock.c,v 1.4 2022/08/12 11:21:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -27,7 +27,9 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_spinlock.c,v 1.3 2022/04/10 11:36:32 riastradh Exp $");
+__RCSID("$NetBSD: t_spinlock.c,v 1.4 2022/08/12 11:21:44 riastradh Exp $");
+
+#include <sys/types.h>
 
 #include <sys/atomic.h>
 #include <sys/param.h>
@@ -76,7 +78,11 @@ unlock(void)
 {
 
 	membar_release();
+#ifdef __HAVE_HASHLOCKED_ATOMICS
+	(void)atomic_cas_uint(&lockbit, 1, 0);
+#else
 	lockbit = 0;
+#endif
 }
 
 static void *

Reply via email to