From 13c86772e981cb947f7264a1a65f3e7ad6dd14d9 Mon Sep 17 00:00:00 2001 From: ad Date: Wed, 28 Nov 2007 16:59:09 +0000 Subject: [PATCH] Memory barrier in respect of the CAS isn't necessary. --- common/lib/libc/atomic/atomic_add_32_cas.c | 5 +---- common/lib/libc/atomic/atomic_add_32_nv_cas.c | 5 +---- common/lib/libc/atomic/atomic_add_64_cas.c | 5 +---- common/lib/libc/atomic/atomic_add_64_nv_cas.c | 5 +---- common/lib/libc/atomic/atomic_and_32_cas.c | 5 +---- common/lib/libc/atomic/atomic_and_32_nv_cas.c | 5 +---- common/lib/libc/atomic/atomic_and_64_cas.c | 5 +---- common/lib/libc/atomic/atomic_and_64_nv_cas.c | 5 +---- common/lib/libc/atomic/atomic_or_32_cas.c | 5 +---- common/lib/libc/atomic/atomic_or_32_nv_cas.c | 5 +---- common/lib/libc/atomic/atomic_or_64_cas.c | 5 +---- common/lib/libc/atomic/atomic_or_64_nv_cas.c | 5 +---- common/lib/libc/atomic/atomic_swap_32_cas.c | 4 +--- common/lib/libc/atomic/atomic_swap_64_cas.c | 4 +--- 14 files changed, 14 insertions(+), 54 deletions(-) diff --git a/common/lib/libc/atomic/atomic_add_32_cas.c b/common/lib/libc/atomic/atomic_add_32_cas.c index 0d108930bab8..7a6bb46096e0 100644 --- a/common/lib/libc/atomic/atomic_add_32_cas.c +++ b/common/lib/libc/atomic/atomic_add_32_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_32_cas.c,v 1.2 2007/11/28 16:54:58 ad Exp $ */ +/* $NetBSD: atomic_add_32_cas.c,v 1.3 2007/11/28 16:59:09 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" void atomic_add_32(volatile uint32_t *addr, int32_t val) @@ -47,9 +46,7 @@ atomic_add_32(volatile uint32_t *addr, int32_t val) uint32_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old + val; } while (atomic_cas_32(addr, old, new) != old); } diff --git a/common/lib/libc/atomic/atomic_add_32_nv_cas.c b/common/lib/libc/atomic/atomic_add_32_nv_cas.c index c48c77149f3e..0d71f0a6e957 100644 --- a/common/lib/libc/atomic/atomic_add_32_nv_cas.c +++ b/common/lib/libc/atomic/atomic_add_32_nv_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_32_nv_cas.c,v 1.2 2007/11/28 16:54:58 ad Exp $ */ +/* $NetBSD: atomic_add_32_nv_cas.c,v 1.3 2007/11/28 16:59:09 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint32_t atomic_add_32_nv(volatile uint32_t *addr, int32_t val) @@ -47,9 +46,7 @@ atomic_add_32_nv(volatile uint32_t *addr, int32_t val) uint32_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old + val; } while (atomic_cas_32(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_add_64_cas.c b/common/lib/libc/atomic/atomic_add_64_cas.c index 7427da5f36b0..d60da4536e6b 100644 --- a/common/lib/libc/atomic/atomic_add_64_cas.c +++ b/common/lib/libc/atomic/atomic_add_64_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_64_cas.c,v 1.2 2007/11/28 16:54:59 ad Exp $ */ +/* $NetBSD: atomic_add_64_cas.c,v 1.3 2007/11/28 16:59:09 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" void atomic_add_64(volatile uint64_t *addr, int64_t val) @@ -47,9 +46,7 @@ atomic_add_64(volatile uint64_t *addr, int64_t val) uint64_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old + val; } while (atomic_cas_64(addr, old, new) != old); } diff --git a/common/lib/libc/atomic/atomic_add_64_nv_cas.c b/common/lib/libc/atomic/atomic_add_64_nv_cas.c index 8b200ad87b69..cb121d5ba5e1 100644 --- a/common/lib/libc/atomic/atomic_add_64_nv_cas.c +++ b/common/lib/libc/atomic/atomic_add_64_nv_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_add_64_nv_cas.c,v 1.2 2007/11/28 16:54:59 ad Exp $ */ +/* $NetBSD: atomic_add_64_nv_cas.c,v 1.3 2007/11/28 16:59:09 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint64_t atomic_add_64_nv(volatile uint64_t *addr, int64_t val) @@ -47,9 +46,7 @@ atomic_add_64_nv(volatile uint64_t *addr, int64_t val) uint64_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old + val; } while (atomic_cas_64(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_and_32_cas.c b/common/lib/libc/atomic/atomic_and_32_cas.c index ecbe9077cd85..6df7713303dc 100644 --- a/common/lib/libc/atomic/atomic_and_32_cas.c +++ b/common/lib/libc/atomic/atomic_and_32_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_and_32_cas.c,v 1.2 2007/11/28 16:55:00 ad Exp $ */ +/* $NetBSD: atomic_and_32_cas.c,v 1.3 2007/11/28 16:59:09 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" void atomic_and_32(volatile uint32_t *addr, uint32_t val) @@ -47,9 +46,7 @@ atomic_and_32(volatile uint32_t *addr, uint32_t val) uint32_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old & val; } while (atomic_cas_32(addr, old, new) != old); } diff --git a/common/lib/libc/atomic/atomic_and_32_nv_cas.c b/common/lib/libc/atomic/atomic_and_32_nv_cas.c index 39ef96e02423..1bbbeb7ab28d 100644 --- a/common/lib/libc/atomic/atomic_and_32_nv_cas.c +++ b/common/lib/libc/atomic/atomic_and_32_nv_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_and_32_nv_cas.c,v 1.2 2007/11/28 16:55:00 ad Exp $ */ +/* $NetBSD: atomic_and_32_nv_cas.c,v 1.3 2007/11/28 16:59:09 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint32_t atomic_and_32_nv(volatile uint32_t *addr, uint32_t val) @@ -47,9 +46,7 @@ atomic_and_32_nv(volatile uint32_t *addr, uint32_t val) uint32_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old & val; } while (atomic_cas_32(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_and_64_cas.c b/common/lib/libc/atomic/atomic_and_64_cas.c index 896f2ac95973..4c08515881fe 100644 --- a/common/lib/libc/atomic/atomic_and_64_cas.c +++ b/common/lib/libc/atomic/atomic_and_64_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_and_64_cas.c,v 1.2 2007/11/28 16:55:01 ad Exp $ */ +/* $NetBSD: atomic_and_64_cas.c,v 1.3 2007/11/28 16:59:10 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" void atomic_and_64(volatile uint64_t *addr, uint64_t val) @@ -47,9 +46,7 @@ atomic_and_64(volatile uint64_t *addr, uint64_t val) uint64_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old & val; } while (atomic_cas_64(addr, old, new) != old); } diff --git a/common/lib/libc/atomic/atomic_and_64_nv_cas.c b/common/lib/libc/atomic/atomic_and_64_nv_cas.c index 182a5c256d44..34f85bd7cad9 100644 --- a/common/lib/libc/atomic/atomic_and_64_nv_cas.c +++ b/common/lib/libc/atomic/atomic_and_64_nv_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_and_64_nv_cas.c,v 1.2 2007/11/28 16:55:01 ad Exp $ */ +/* $NetBSD: atomic_and_64_nv_cas.c,v 1.3 2007/11/28 16:59:10 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint64_t atomic_and_64_nv(volatile uint64_t *addr, uint64_t val) @@ -47,9 +46,7 @@ atomic_and_64_nv(volatile uint64_t *addr, uint64_t val) uint64_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old & val; } while (atomic_cas_64(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_or_32_cas.c b/common/lib/libc/atomic/atomic_or_32_cas.c index d16af05c8609..492e8d53c716 100644 --- a/common/lib/libc/atomic/atomic_or_32_cas.c +++ b/common/lib/libc/atomic/atomic_or_32_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_32_cas.c,v 1.2 2007/11/28 16:55:08 ad Exp $ */ +/* $NetBSD: atomic_or_32_cas.c,v 1.3 2007/11/28 16:59:10 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" void atomic_or_32(volatile uint32_t *addr, uint32_t val) @@ -47,9 +46,7 @@ atomic_or_32(volatile uint32_t *addr, uint32_t val) uint32_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old | val; } while (atomic_cas_32(addr, old, new) != old); } diff --git a/common/lib/libc/atomic/atomic_or_32_nv_cas.c b/common/lib/libc/atomic/atomic_or_32_nv_cas.c index e1a1bfa8d214..d8cdffaa452e 100644 --- a/common/lib/libc/atomic/atomic_or_32_nv_cas.c +++ b/common/lib/libc/atomic/atomic_or_32_nv_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_32_nv_cas.c,v 1.2 2007/11/28 16:55:09 ad Exp $ */ +/* $NetBSD: atomic_or_32_nv_cas.c,v 1.3 2007/11/28 16:59:10 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint32_t atomic_or_32_nv(volatile uint32_t *addr, uint32_t val) @@ -47,9 +46,7 @@ atomic_or_32_nv(volatile uint32_t *addr, uint32_t val) uint32_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old | val; } while (atomic_cas_32(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_or_64_cas.c b/common/lib/libc/atomic/atomic_or_64_cas.c index ccc249bca8f6..4f7480d9cb3a 100644 --- a/common/lib/libc/atomic/atomic_or_64_cas.c +++ b/common/lib/libc/atomic/atomic_or_64_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_64_cas.c,v 1.2 2007/11/28 16:55:09 ad Exp $ */ +/* $NetBSD: atomic_or_64_cas.c,v 1.3 2007/11/28 16:59:10 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" void atomic_or_64(volatile uint64_t *addr, uint64_t val) @@ -47,9 +46,7 @@ atomic_or_64(volatile uint64_t *addr, uint64_t val) uint64_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old | val; } while (atomic_cas_64(addr, old, new) != old); } diff --git a/common/lib/libc/atomic/atomic_or_64_nv_cas.c b/common/lib/libc/atomic/atomic_or_64_nv_cas.c index 78a2cbcf429a..77a91e797b50 100644 --- a/common/lib/libc/atomic/atomic_or_64_nv_cas.c +++ b/common/lib/libc/atomic/atomic_or_64_nv_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_or_64_nv_cas.c,v 1.2 2007/11/28 16:55:10 ad Exp $ */ +/* $NetBSD: atomic_or_64_nv_cas.c,v 1.3 2007/11/28 16:59:11 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint64_t atomic_or_64_nv(volatile uint64_t *addr, uint64_t val) @@ -47,9 +46,7 @@ atomic_or_64_nv(volatile uint64_t *addr, uint64_t val) uint64_t old, new; do { - OP_READ_BARRIER; old = *addr; - new = old | val; } while (atomic_cas_64(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_swap_32_cas.c b/common/lib/libc/atomic/atomic_swap_32_cas.c index 4b0b79b04ff3..b886e578f74b 100644 --- a/common/lib/libc/atomic/atomic_swap_32_cas.c +++ b/common/lib/libc/atomic/atomic_swap_32_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_32_cas.c,v 1.2 2007/11/28 16:55:11 ad Exp $ */ +/* $NetBSD: atomic_swap_32_cas.c,v 1.3 2007/11/28 16:59:11 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint32_t atomic_swap_32(volatile uint32_t *addr, uint32_t new) @@ -47,7 +46,6 @@ atomic_swap_32(volatile uint32_t *addr, uint32_t new) uint32_t old; do { - OP_READ_BARRIER; old = *addr; } while (atomic_cas_32(addr, old, new) != old); diff --git a/common/lib/libc/atomic/atomic_swap_64_cas.c b/common/lib/libc/atomic/atomic_swap_64_cas.c index f3c7c4f89c04..39cd9dd5999e 100644 --- a/common/lib/libc/atomic/atomic_swap_64_cas.c +++ b/common/lib/libc/atomic/atomic_swap_64_cas.c @@ -1,4 +1,4 @@ -/* $NetBSD: atomic_swap_64_cas.c,v 1.2 2007/11/28 16:55:11 ad Exp $ */ +/* $NetBSD: atomic_swap_64_cas.c,v 1.3 2007/11/28 16:59:11 ad Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -39,7 +39,6 @@ #include "atomic_op_namespace.h" #include -#include "atomic_op_cas_impl.h" uint64_t atomic_swap_64(volatile uint64_t *addr, uint64_t new) @@ -47,7 +46,6 @@ atomic_swap_64(volatile uint64_t *addr, uint64_t new) uint64_t old; do { - OP_READ_BARRIER; old = *addr; } while (atomic_cas_64(addr, old, new) != old);