all repos — mgba @ c353e1254afbb7235911b406adad4d32db55085c

mGBA Game Boy Advance Emulator

PowerPC: Fix overflow in LOAD/STORE_64LE (fixes #1089)
Vicki Pfau vi@endrift.com
Sat, 26 May 2018 13:09:13 -0700
commit

c353e1254afbb7235911b406adad4d32db55085c

parent

7f41dd354176b720c8e3310553c6b772278b9dca

1 files changed, 5 insertions(+), 4 deletions(-)

jump to
M include/mgba-util/common.hinclude/mgba-util/common.h

@@ -136,12 +136,13 @@ uint32_t hi; \

uint32_t lo; \ }; \ uint64_t b64; \ - } *bswap = (void*) &DEST; \ + } bswap; \ const void* _ptr = (ARR); \ __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)) ; \ + DEST = bswap.b64; \ } #define STORE_64LE(SRC, ADDR, ARR) { \

@@ -152,12 +153,12 @@ uint32_t hi; \

uint32_t lo; \ }; \ uint64_t b64; \ - } *bswap = (void*) &SRC; \ + } bswap = { .b64 = SRC }; \ const void* _ptr = (ARR); \ __asm__( \ "stwbrx %0, %2, %3 \n" \ "stwbrx %1, %2, %4 \n" \ - : : "r"(bswap->hi), "r"(bswap->lo), "b"(_ptr), "r"(_addr), "r"(_addr + 4) : "memory"); \ + : : "r"(bswap.hi), "r"(bswap.lo), "b"(_ptr), "r"(_addr), "r"(_addr + 4) : "memory"); \ } #elif defined(__llvm__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)