aboutsummaryrefslogtreecommitdiff
path: root/lib/netdev-dummy.c
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2013-07-30 15:31:48 -0700
committerBen Pfaff <blp@nicira.com>2013-07-30 21:30:45 -0700
commit97be153858b4cd175cbe7862b8e1624bf22ab98a (patch)
treeab1e518bef4e8bbc97fe8a069d9b91541bb9c4d4 /lib/netdev-dummy.c
parent2b51596fdeba7fbf4caff323dd6af375e7f84596 (diff)
clang: Add annotations for thread safety check.
This commit adds annotations for thread safety check. And the check can be conducted by using -Wthread-safety flag in clang. Co-authored-by: Alex Wang <alexw@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netdev-dummy.c')
-rw-r--r--lib/netdev-dummy.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 82473a17..c4f58b7a 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -241,16 +241,11 @@ static int
netdev_dummy_create(const struct netdev_class *class, const char *name,
struct netdev **netdevp)
{
- static unsigned int next_n = 0xaa550000;
- static pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER;
-
+ static atomic_uint next_n = ATOMIC_VAR_INIT(0xaa550000);
struct netdev_dummy *netdev;
unsigned int n;
- xpthread_mutex_lock(&mutex);
- n = next_n++;
- xpthread_mutex_unlock(&mutex);
-
+ atomic_add(&next_n, 1, &n);
netdev = xzalloc(sizeof *netdev);
netdev_init(&netdev->up, name, class);
netdev->hwaddr[0] = 0xaa;