From c2323dd4d2a65420f77c73f7b55c41ba469a47f8 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sun, 16 Aug 2015 15:18:42 +0200 Subject: [PATCH] really fix ARM locking - was writing 0 to lock variable, so was ineffective - only exit loop if both lock was 0 and strex was successful --- common_arm.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/common_arm.h b/common_arm.h index 1351910..2dabd4d 100644 --- a/common_arm.h +++ b/common_arm.h @@ -59,22 +59,16 @@ static void __inline blas_lock(volatile BLASULONG *address){ while (*address) {YIELDING;}; __asm__ __volatile__( - "1: \n\t" - "ldrex r2, [%1] \n\t" - "mov r2, #0 \n\t" - "strex r3, r2, [%1] \n\t" - "cmp r3, #0 \n\t" - "bne 1b \n\t" - "mov %0 , r3 \n\t" - : "=r"(ret), "=r"(address) - : "1"(address) - : "memory", "r2" , "r3" - - + "ldrex r2, [%1] \n\t" + "strex %0, %2, [%1] \n\t" + "orr %0, r2 \n\t" + : "=&r"(ret) + : "r"(address), "r"(1) + : "memory", "r2" ); } while (ret); - + MB; } -- 2.7.4