lib/netdev-dummy: Use relaxed atomics for a trivial counter.
authorJarno Rajahalme <jrajahalme@nicira.com>
Fri, 29 Aug 2014 17:34:53 +0000 (10:34 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Fri, 29 Aug 2014 17:34:53 +0000 (10:34 -0700)
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@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/netdev-dummy.c

index 8d1c298..dd78818 100644 (file)
@@ -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);