Trivial ID counters do not synchronize anything, therefore can use
atomic_count.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
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);
}
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));
}
\f
static uint32_t
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);