From da8357a33964b91a731a2b7209b8e9335689b7aa Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 25 May 2018 17:33:59 -0700 Subject: [PATCH] PowerPC: Fix potential register clobbering in LOAD_64LE --- include/mgba-util/common.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mgba-util/common.h b/include/mgba-util/common.h index 45961ddbb..13bb1979f 100644 --- a/include/mgba-util/common.h +++ b/include/mgba-util/common.h @@ -119,13 +119,13 @@ typedef intptr_t ssize_t; #define STORE_32LE(SRC, ADDR, ARR) { \ uint32_t _addr = (ADDR); \ void* _ptr = (ARR); \ - __asm__("stwbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr)); \ + __asm__("stwbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr) : "memory"); \ } #define STORE_16LE(SRC, ADDR, ARR) { \ uint32_t _addr = (ADDR); \ void* _ptr = (ARR); \ - __asm__("sthbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr)); \ + __asm__("sthbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr) : "memory"); \ } #define LOAD_64LE(DEST, ADDR, ARR) { \ @@ -141,7 +141,7 @@ typedef intptr_t ssize_t; __asm__( \ "lwbrx %0, %2, %3 \n" \ "lwbrx %1, %2, %4 \n" \ - : "=r"(bswap->lo), "=r"(bswap->hi) : "b"(_ptr), "r"(_addr), "r"(_addr + 4)); \ + : "=&r"(bswap->lo), "=&r"(bswap->hi) : "b"(_ptr), "r"(_addr), "r"(_addr + 4)) ; \ } #define STORE_64LE(SRC, ADDR, ARR) { \ @@ -157,7 +157,7 @@ typedef intptr_t ssize_t; __asm__( \ "stwbrx %0, %2, %3 \n" \ "stwbrx %1, %2, %4 \n" \ - : : "r"(bswap->hi), "r"(bswap->lo), "b"(_ptr), "r"(_addr), "r"(_addr + 4)); \ + : : "r"(bswap->hi), "r"(bswap->lo), "b"(_ptr), "r"(_addr), "r"(_addr + 4) : "memory"); \ } #elif defined(__llvm__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)