[ovs-dev] [PATCH 13/18] lib/netdev-dummy: Use relaxed atomics for a trivial counter.

Jarno Rajahalme jrajahalme at nicira.com
Fri Aug 22 20:58:24 UTC 2014


Even though there is no need to optimize netdev-dummy, it might be
good to do this right, in case it serves as an inspiration for
something else later.

Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
 lib/netdev-dummy.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 8d1c298..dd78818 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -625,11 +625,11 @@ netdev_dummy_alloc(void)
 static int
 netdev_dummy_construct(struct netdev *netdev_)
 {
-    static atomic_uint next_n = ATOMIC_VAR_INIT(0xaa550000);
+    static atomic_count next_n = ATOMIC_COUNT_INIT(0xaa550000);
     struct netdev_dummy *netdev = netdev_dummy_cast(netdev_);
     unsigned int n;
 
-    atomic_add(&next_n, 1, &n);
+    n = atomic_count_inc(&next_n);
 
     ovs_mutex_init(&netdev->mutex);
     ovs_mutex_lock(&netdev->mutex);
-- 
1.7.10.4




More information about the dev mailing list