Skip to content

Commit

Permalink
Wii: Fix ppc32 endianness regression
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Oct 29, 2020
1 parent 711a60e commit 5b7d0b1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/mgba-util/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,32 @@ typedef intptr_t ssize_t;
#define LOAD_32BE(DEST, ADDR, ARR) DEST = *(uint32_t*) ((uintptr_t) (ARR) + (size_t) (ADDR))
#if defined(__PPC__) || defined(__POWERPC__)
#define LOAD_32LE(DEST, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
const void* _ptr = (ARR); \
__asm__("lwbrx %0, %1, %2" : "=r"(DEST) : "b"(_ptr), "r"(_addr)); \
}

#define LOAD_16LE(DEST, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
const void* _ptr = (ARR); \
__asm__("lhbrx %0, %1, %2" : "=r"(DEST) : "b"(_ptr), "r"(_addr)); \
}

#define STORE_32LE(SRC, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
void* _ptr = (ARR); \
__asm__("stwbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr) : "memory"); \
}

#define STORE_16LE(SRC, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
void* _ptr = (ARR); \
__asm__("sthbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr) : "memory"); \
}

#ifndef _ARCH_PWR7
#define LOAD_64LE(DEST, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
union { \
struct { \
uint32_t hi; \
Expand All @@ -176,7 +176,7 @@ typedef intptr_t ssize_t;
}

#define STORE_64LE(SRC, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
union { \
struct { \
uint32_t hi; \
Expand All @@ -192,13 +192,13 @@ typedef intptr_t ssize_t;
}
#else
#define LOAD_64LE(DEST, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
const void* _ptr = (ARR); \
__asm__("ldbrx %0, %1, %2" : "=r"(DEST) : "b"(_ptr), "r"(_addr)); \
}

#define STORE_64LE(SRC, ADDR, ARR) { \
off_t _addr = (ADDR); \
size_t _addr = (ADDR); \
void* _ptr = (ARR); \
__asm__("stdbrx %0, %1, %2" : : "r"(SRC), "b"(_ptr), "r"(_addr) : "memory"); \
}
Expand Down

0 comments on commit 5b7d0b1

Please sign in to comment.