aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.c
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/svm/svm_fifo.c
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/svm/svm_fifo.c')
-rw-r--r--src/svm/svm_fifo.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index 4eae0a1c7e6..aa523c6b55c 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -513,7 +513,7 @@ CLIB_MARCH_FN (svm_fifo_enqueue_nowait, int, svm_fifo_t * f, u32 max_bytes,
/* Atomically increase the queue length */
ASSERT (cursize + total_copy_bytes <= nitems);
- __sync_fetch_and_add (&f->cursize, total_copy_bytes);
+ clib_atomic_fetch_add (&f->cursize, total_copy_bytes);
return (total_copy_bytes);
}
@@ -659,7 +659,7 @@ CLIB_MARCH_FN (svm_fifo_dequeue_nowait, int, svm_fifo_t * f, u32 max_bytes,
ASSERT (f->head <= nitems);
ASSERT (cursize >= total_copy_bytes);
- __sync_fetch_and_sub (&f->cursize, total_copy_bytes);
+ clib_atomic_fetch_sub (&f->cursize, total_copy_bytes);
return (total_copy_bytes);
}
@@ -757,7 +757,7 @@ svm_fifo_dequeue_drop (svm_fifo_t * f, u32 max_bytes)
ASSERT (f->head <= nitems);
ASSERT (cursize >= total_drop_bytes);
- __sync_fetch_and_sub (&f->cursize, total_drop_bytes);
+ clib_atomic_fetch_sub (&f->cursize, total_drop_bytes);
return total_drop_bytes;
}
@@ -766,7 +766,7 @@ void
svm_fifo_dequeue_drop_all (svm_fifo_t * f)
{
f->head = f->tail;
- __sync_fetch_and_sub (&f->cursize, f->cursize);
+ clib_atomic_fetch_sub (&f->cursize, f->cursize);
}
int
@@ -813,7 +813,7 @@ svm_fifo_segments_free (svm_fifo_t * f, svm_fifo_segment_t * fs)
f->head = (f->head + fs[0].len) % f->nitems;
total_drop_bytes = fs[0].len;
}
- __sync_fetch_and_sub (&f->cursize, total_drop_bytes);
+ clib_atomic_fetch_sub (&f->cursize, total_drop_bytes);
}
u32