diff options
author | Sirshak Das <sirshak.das@arm.com> | 2018-10-03 22:53:51 +0000 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-10-19 07:10:47 +0000 |
commit | 2f6d7bb93c157b874efb79a2d1583a4c368bf89a (patch) | |
tree | 05dc2867c598cbb8d711f074b4b0eb62dd464f41 /src/vlib/threads.h | |
parent | bf3443b0f852f5a4c551d12f926defbd047f2161 (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/vlib/threads.h')
-rw-r--r-- | src/vlib/threads.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/vlib/threads.h b/src/vlib/threads.h index bb7c164c2e3..0e9cba52103 100644 --- a/src/vlib/threads.h +++ b/src/vlib/threads.h @@ -414,7 +414,7 @@ vlib_worker_thread_barrier_check (void) ed->thread_index = thread_index; } - clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, 1); + clib_atomic_fetch_add (vlib_worker_threads->workers_at_barrier, 1); if (CLIB_DEBUG > 0) { vm = vlib_get_main (); @@ -424,7 +424,7 @@ vlib_worker_thread_barrier_check (void) ; if (CLIB_DEBUG > 0) vm->parked_at_barrier = 0; - clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, -1); + clib_atomic_fetch_add (vlib_worker_threads->workers_at_barrier, -1); if (PREDICT_FALSE (*vlib_worker_threads->node_reforks_required)) { @@ -450,8 +450,8 @@ vlib_worker_thread_barrier_check (void) } vlib_worker_thread_node_refork (); - clib_smp_atomic_add (vlib_worker_threads->node_reforks_required, - -1); + clib_atomic_fetch_add (vlib_worker_threads->node_reforks_required, + -1); while (*vlib_worker_threads->node_reforks_required) ; } @@ -519,7 +519,7 @@ vlib_get_frame_queue_elt (u32 frame_queue_index, u32 index) fq = fqm->vlib_frame_queues[index]; ASSERT (fq); - new_tail = __sync_add_and_fetch (&fq->tail, 1); + new_tail = clib_atomic_add_fetch (&fq->tail, 1); /* Wait until a ring slot is available */ while (new_tail >= fq->head_hint + fq->nelts) |