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
This commit is contained in:
Grazvydas Ignotas 2015-08-16 15:18:42 +02:00
parent bb6e050509
commit c2323dd4d2
1 changed files with 7 additions and 13 deletions

View File

@ -59,22 +59,16 @@ static void __inline blas_lock(volatile BLASULONG *address){
while (*address) {YIELDING;}; while (*address) {YIELDING;};
__asm__ __volatile__( __asm__ __volatile__(
"1: \n\t" "ldrex r2, [%1] \n\t"
"ldrex r2, [%1] \n\t" "strex %0, %2, [%1] \n\t"
"mov r2, #0 \n\t" "orr %0, r2 \n\t"
"strex r3, r2, [%1] \n\t" : "=&r"(ret)
"cmp r3, #0 \n\t" : "r"(address), "r"(1)
"bne 1b \n\t" : "memory", "r2"
"mov %0 , r3 \n\t"
: "=r"(ret), "=r"(address)
: "1"(address)
: "memory", "r2" , "r3"
); );
} while (ret); } while (ret);
MB;
} }