From 1d121852c12a87060989842e4d86920f5dde0b5d Mon Sep 17 00:00:00 2001 From: Ashwin Sekhar T K Date: Fri, 20 Nov 2015 01:45:35 +0530 Subject: [PATCH] Fix blas_lock for arm64 --- common_arm64.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/common_arm64.h b/common_arm64.h index 1fa312d35..d9d5d215c 100644 --- a/common_arm64.h +++ b/common_arm64.h @@ -43,28 +43,39 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSEMBLER + static void __inline blas_lock(volatile BLASULONG *address){ - long register ret; + BLASULONG ret; do { while (*address) {YIELDING;}; __asm__ __volatile__( - "ldaxr %0, [%1] \n\t" - "stlxr w2, %2, [%1] \n\t" - "orr %0, %0, x2 \n\t" - : "=r"(ret) - : "r"(address), "r"(1l) - : "memory", "x2" + "mov x4, #1 \n\t" + "1: \n\t" + "ldaxr x2, [%1] \n\t" + "cbnz x2, 1b \n\t" + "2: \n\t" + "stxr w3, x4, [%1] \n\t" + "cbnz w3, 1b \n\t" + "mov %0, #0 \n\t" + : "=r"(ret), "=r"(address) + : "1"(address) + : "memory", "x2" , "x3", "x4" + + ); + } while (ret); - MB; + } + #define BLAS_LOCK_DEFINED + static inline int blas_quickdivide(blasint x, blasint y){ return x / y; }