@@ -12,9 +12,8 @@
void odp_ticketlock_init(odp_ticketlock_t *ticketlock)
{
- ticketlock->next_ticket = 0;
+ odp_atomic_init_u32(&ticketlock->next_ticket, 0);
ticketlock->cur_ticket = 0;
- odp_sync_stores();
}
@@ -27,7 +26,7 @@ void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)
while (ticket != ticketlock->cur_ticket)
odp_spin();
- odp_mem_barrier();
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
}
@@ -38,14 +37,15 @@ void odp_ticketlock_unlock(odp_ticketlock_t *ticketlock)
ticketlock->cur_ticket++;
#if defined __OCTEON__
- odp_sync_stores();
+ odp_sync_stores(); /* Possibly SYNCW instead of SYNC */
#else
- odp_mem_barrier();
+ __atomic_thread_fence(__ATOMIC_RELEASE);
#endif
}
int odp_ticketlock_is_locked(odp_ticketlock_t *ticketlock)
{
- return ticketlock->cur_ticket != ticketlock->next_ticket;
+ return ticketlock->cur_ticket !=
+ odp_atomic_load_u32(&ticketlock->next_ticket);
}
Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org> --- platform/linux-generic/odp_ticketlock.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)