summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_det.h
diff options
context:
space:
mode:
authorSirshak Das <sirshak.das@arm.com>2018-10-03 22:53:51 +0000
committerDamjan Marion <dmarion@me.com>2018-10-19 07:10:47 +0000
commit2f6d7bb93c157b874efb79a2d1583a4c368bf89a (patch)
tree05dc2867c598cbb8d711f074b4b0eb62dd464f41 /src/plugins/nat/nat_det.h
parentbf3443b0f852f5a4c551d12f926defbd047f2161 (diff)
vppinfra: add atomic macros for __sync builtins
This is first part of addition of atomic macros with only macros for __sync builtins. - Based on earlier patch by Damjan (https://gerrit.fd.io/r/#/c/10729/) Additionally - clib_atomic_release macro added and used in the absence of any memory barrier. - clib_atomic_bool_cmp_and_swap added Change-Id: Ie4e48c1e184a652018d1d0d87c4be80ddd180a3b Original-patch-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Sirshak Das <sirshak.das@arm.com> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com> Reviewed-by: Steve Capper <steve.capper@arm.com>
Diffstat (limited to 'src/plugins/nat/nat_det.h')
-rw-r--r--src/plugins/nat/nat_det.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/nat/nat_det.h b/src/plugins/nat/nat_det.h
index ce876bca9fb..7878a4c4ed6 100644
--- a/src/plugins/nat/nat_det.h
+++ b/src/plugins/nat/nat_det.h
@@ -159,13 +159,13 @@ snat_det_ses_create (snat_det_map_t * dm, ip4_address_t * in_addr,
{
if (!dm->sessions[i + user_offset].in_port)
{
- if (__sync_bool_compare_and_swap
+ if (clib_atomic_bool_cmp_and_swap
(&dm->sessions[i + user_offset].in_port, 0, in_port))
{
dm->sessions[i + user_offset].out.as_u64 = out->as_u64;
dm->sessions[i + user_offset].state = SNAT_SESSION_UNKNOWN;
dm->sessions[i + user_offset].expire = 0;
- __sync_add_and_fetch (&dm->ses_num, 1);
+ clib_atomic_add_fetch (&dm->ses_num, 1);
return &dm->sessions[i + user_offset];
}
}
@@ -179,10 +179,10 @@ snat_det_ses_create (snat_det_map_t * dm, ip4_address_t * in_addr,
always_inline void
snat_det_ses_close (snat_det_map_t * dm, snat_det_session_t * ses)
{
- if (__sync_bool_compare_and_swap (&ses->in_port, ses->in_port, 0))
+ if (clib_atomic_bool_cmp_and_swap (&ses->in_port, ses->in_port, 0))
{
ses->out.as_u64 = 0;
- __sync_add_and_fetch (&dm->ses_num, -1);
+ clib_atomic_add_fetch (&dm->ses_num, -1);
}
}