Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libc/atomic libc/atomic: Fix membars in __atomic_...
details: https://anonhg.NetBSD.org/src/rev/d7b4fae333f7
branches: trunk
changeset: 365151:d7b4fae333f7
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Apr 09 23:38:57 2022 +0000
description:
libc/atomic: Fix membars in __atomic_load/store_* stubs.
- membar_enter/exit ordering was backwards.
- membar_enter doesn't make any sense for load anyway.
- Switch to membar_release for store and membar_acquire for load.
The only sensible orderings for a simple load or store are acquire or
release, respectively, or sequential consistency. This never
provided correct sequential consistency before -- we should really
make it conditional on memmodel but I don't know offhand what the
values of memmodel might be and this is at least better than before.
diffstat:
common/lib/libc/atomic/atomic_load.c | 7 +++----
common/lib/libc/atomic/atomic_store.c | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diffs (58 lines):
diff -r 114adf1cc9f0 -r d7b4fae333f7 common/lib/libc/atomic/atomic_load.c
--- a/common/lib/libc/atomic/atomic_load.c Sat Apr 09 23:38:31 2022 +0000
+++ b/common/lib/libc/atomic/atomic_load.c Sat Apr 09 23:38:57 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_load.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */
+/* $NetBSD: atomic_load.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: atomic_load.c,v 1.3 2020/09/07 00:52:19 mrg Exp $");
+__RCSID("$NetBSD: atomic_load.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $");
#include "atomic_op_namespace.h"
@@ -40,9 +40,8 @@
__atomic_load_ ## n(const volatile void *ptr, int memmodel) \
{ \
uint## b ##_t val; \
- membar_enter(); \
val = *(const volatile uint ## b ## _t *)ptr; \
- membar_exit(); \
+ membar_acquire(); \
return val; \
}
diff -r 114adf1cc9f0 -r d7b4fae333f7 common/lib/libc/atomic/atomic_store.c
--- a/common/lib/libc/atomic/atomic_store.c Sat Apr 09 23:38:31 2022 +0000
+++ b/common/lib/libc/atomic/atomic_store.c Sat Apr 09 23:38:57 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_store.c,v 1.3 2020/09/07 00:52:19 mrg Exp $ */
+/* $NetBSD: atomic_store.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: atomic_store.c,v 1.3 2020/09/07 00:52:19 mrg Exp $");
+__RCSID("$NetBSD: atomic_store.c,v 1.4 2022/04/09 23:38:57 riastradh Exp $");
#include "atomic_op_namespace.h"
@@ -40,9 +40,8 @@
__atomic_store_ ## n(volatile void *ptr, uint ## b ## _t val, \
int memmodel) \
{ \
- membar_enter(); \
+ membar_release(); \
*(volatile uint ## b ## _t *)ptr = val; \
- membar_exit(); \
}
atomic_store_n(1, 8)
Home |
Main Index |
Thread Index |
Old Index