Skip to content

Commit 3f1b576

Browse files
committed
Fix blas lock bug on AArch64.
1 parent d8f18d3 commit 3f1b576

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

common_arm64.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,22 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4646
static void __inline blas_lock(volatile BLASULONG *address){
4747

4848
int register ret;
49+
int register tmp;
4950

5051
do {
5152
while (*address) {YIELDING;};
5253

5354
__asm__ __volatile__(
5455
"1: \n\t"
55-
"ldrex r2, [%1] \n\t"
56-
"mov r2, #0 \n\t"
57-
"strex r3, r2, [%1] \n\t"
58-
"cmp r3, #0 \n\t"
59-
"bne 1b \n\t"
60-
"mov %0 , r3 \n\t"
61-
: "=r"(ret), "=r"(address)
56+
"ldaxr %2, [%1] \n\t"
57+
"mov %2, #0 \n\t"
58+
"stlxr %w0, %2, [%1] \n\t"
59+
"cbnz %w0, 1b \n\t"
60+
"mov %0 , #0 \n\t"
61+
: "=r"(ret), "=r"(address), "=r"(tmp)
6262
: "1"(address)
63-
: "memory", "r2" , "r3"
63+
: "memory", "%w0"
64+
//, "%r2" , "%r3"
6465

6566

6667
);

0 commit comments

Comments
 (0)