diff options
author | Ethan Jackson <ethan@nicira.com> | 2013-07-30 15:31:48 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-07-30 21:30:45 -0700 |
commit | 97be153858b4cd175cbe7862b8e1624bf22ab98a (patch) | |
tree | ab1e518bef4e8bbc97fe8a069d9b91541bb9c4d4 /lib/ofp-msgs.c | |
parent | 2b51596fdeba7fbf4caff323dd6af375e7f84596 (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/ofp-msgs.c')
-rw-r--r-- | lib/ofp-msgs.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index 8bb1754f..d136f73d 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -110,14 +110,10 @@ static enum ofperr ofpraw_from_ofphdrs(enum ofpraw *, const struct ofphdrs *); static ovs_be32 alloc_xid(void) { - static uint32_t next_xid = 1; - static pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER; + static atomic_uint32_t next_xid = ATOMIC_VAR_INIT(1); uint32_t xid; - xpthread_mutex_lock(&mutex); - xid = next_xid++; - xpthread_mutex_unlock(&mutex); - + atomic_add(&next_xid, 1, &xid); return htonl(xid); } |