diff mbox

[4/7] linux-generic: odp_ticketlock.c: use odp_atomic.h and __atomic (tmp), added missing barrier

Message ID 1416484428-23849-5-git-send-email-ola.liljedahl@linaro.org
State New
Headers show

Commit Message

Ola Liljedahl Nov. 20, 2014, 11:53 a.m. UTC
Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
 platform/linux-generic/odp_ticketlock.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_ticketlock.c b/platform/linux-generic/odp_ticketlock.c
index be5b885..dc6ff83 100644
--- a/platform/linux-generic/odp_ticketlock.c
+++ b/platform/linux-generic/odp_ticketlock.c
@@ -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);
 }