Trivial ID counters do not synchronize anything, therefore can use atomic_count.
Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- lib/jsonrpc.c | 4 ++-- lib/ofp-msgs.c | 6 ++---- lib/ofp-parse.c | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index 842d117..0841ad8 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -516,10 +516,10 @@ jsonrpc_create(enum jsonrpc_msg_type type, const char *method, static struct json * jsonrpc_create_id(void) { - static atomic_uint next_id = ATOMIC_VAR_INIT(0); + static atomic_count next_id = ATOMIC_COUNT_INIT(0); unsigned int id; - atomic_add(&next_id, 1, &id); + id = atomic_count_inc(&next_id); return json_integer_create(id); } diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index 3e93466..904aba6 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -110,11 +110,9 @@ static enum ofperr ofpraw_from_ofphdrs(enum ofpraw *, const struct ofphdrs *); static ovs_be32 alloc_xid(void) { - static atomic_uint32_t next_xid = ATOMIC_VAR_INIT(1); - uint32_t xid; + static atomic_count next_xid = ATOMIC_COUNT_INIT(1); - atomic_add(&next_xid, 1, &xid); - return htonl(xid); + return htonl(atomic_count_inc(&next_xid)); } static uint32_t diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index 9bafa8d..eed5a08 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -730,11 +730,11 @@ parse_flow_monitor_request__(struct ofputil_flow_monitor_request *fmr, const char *str_, char *string, enum ofputil_protocol *usable_protocols) { - static atomic_uint32_t id = ATOMIC_VAR_INIT(0); + static atomic_count id = ATOMIC_COUNT_INIT(0); char *save_ptr = NULL; char *name; - atomic_add(&id, 1, &fmr->id); + fmr->id = atomic_count_inc(&id); fmr->flags = (NXFMF_INITIAL | NXFMF_ADD | NXFMF_DELETE | NXFMF_MODIFY | NXFMF_OWN | NXFMF_ACTIONS); -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev