summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2019-12-01 15:28:19 +0000
committerriastradh <riastradh@NetBSD.org>2019-12-01 15:28:19 +0000
commit186decc2e1f11e0d7033a8b056d1ec96551ad247 (patch)
tree7eb9f2ded9103cf935789c27dae0806fb76f6e1e /tests
parentb190e016bb2163c85a2b316635812bf378387cbb (diff)
Adapt <sys/pslist.h> to use atomic_load/store_*.
Changes: - membar_producer(); *p = v; => atomic_store_release(p, v); (Effectively like using membar_exit instead of membar_producer, which is what we should have been doing all along so that stores by the `reader' can't affect earlier loads by the writer, such as KASSERT(p->refcnt == 0) in the writer and atomic_inc(&p->refcnt) in the reader.) - p = *pp; if (p != NULL) membar_datadep_consumer(); => p = atomic_load_consume(pp); (Only makes a difference on DEC Alpha. As long as lists generally have at least one element, this is not likely to make a big difference, and keeps the code simpler and clearer.) No other functional change intended. While here, annotate each synchronizing load and store with its counterpart in a comment.
Diffstat (limited to 'tests')
-rw-r--r--tests/include/sys/t_pslist.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/include/sys/t_pslist.c b/tests/include/sys/t_pslist.c
index f46ed5764c3..464de395a83 100644
--- a/tests/include/sys/t_pslist.c
+++ b/tests/include/sys/t_pslist.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pslist.c,v 1.1 2016/04/09 04:39:47 riastradh Exp $ */
+/* $NetBSD: t_pslist.c,v 1.2 2019/12/01 15:28:20 riastradh Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -29,16 +29,23 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/pslist.h>
-
-#include <atf-c.h>
-
/*
* XXX This is a limited test to make sure the operations behave as
* described on a sequential machine. It does nothing to test the
- * pserialize-safety of any operations.
+ * pserialize-safety of any operations. The following definitions must
+ * be replaced in any parallel tests.
*/
+#define atomic_load_relaxed(p) (*(p))
+#define atomic_load_acquire(p) (*(p))
+#define atomic_load_consume(p) (*(p))
+#define atomic_store_relaxed(p,v) (*(p) = (v))
+#define atomic_store_release(p,v) (*(p) = (v))
+
+#include <sys/pslist.h>
+
+#include <atf-c.h>
+
ATF_TC(misc);
ATF_TC_HEAD(misc, tc)
{