From 0a5a099059f866d51a08a90c1d27a5a737c7f401 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 1 Oct 2014 09:33:37 +0000 Subject: [PATCH] Make PPC asm directives a bit more resilient to different compilers --- src/arm/common.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/arm/common.h b/src/arm/common.h index 91999ca9f..db2fb16e2 100644 --- a/src/arm/common.h +++ b/src/arm/common.h @@ -17,10 +17,25 @@ #define UNUSED(V) (void)(V) #if defined(__PPC__) || defined(__POWERPC__) -#define LOAD_32(DEST, ADDR, ARR) asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR)) -#define LOAD_16(DEST, ADDR, ARR) asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR)) -#define STORE_32(SRC, ADDR, ARR) asm("stwbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR)) -#define STORE_16(SRC, ADDR, ARR) asm("sthbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR)) +#define LOAD_32(DEST, ADDR, ARR) { \ + uint32_t _tmp = (ADDR); \ + asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(_tmp), "p"(ARR)); \ +} + +#define LOAD_16(DEST, ADDR, ARR) { \ + uint16_t _tmp = (ADDR); \ + asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(_tmp), "p"(ARR)); \ +} + +#define STORE_32(SRC, ADDR, ARR) { \ + uint32_t _tmp = (ADDR); \ + asm("stwbrx %0, %1, %2" : : "r"(SRC), "r"(_tmp), "p"(ARR)); \ +} + +#define STORE_16(SRC, ADDR, ARR) { \ + uint16_t _tmp = (ADDR); \ + asm("sthbrx %0, %1, %2" : : "r"(SRC), "r"(_tmp), "p"(ARR)); \ +} #else #define LOAD_32(DEST, ADDR, ARR) DEST = ((uint32_t*) ARR)[(ADDR) >> 2] #define LOAD_16(DEST, ADDR, ARR) DEST = ((uint16_t*) ARR)[(ADDR) >> 1]