From 9e22f62e0db9995d62bd0ecf3008c15754618634 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 28 Dec 2020 11:50:02 +0300 Subject: [PATCH] arm64 implementations of SDL_Swap16/32 (bug #5419.) patch from David Carlier. --- include/SDL_endian.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/SDL_endian.h b/include/SDL_endian.h index 171c008a8..b11a83a61 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -92,6 +92,13 @@ SDL_Swap16(Uint16 x) __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); return (Uint16)result; } +#elif defined(__GNUC__) && defined(__aarch64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rev16 %w1, %w0" : "=r"(x) : "r"(x)); + return x; +} #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) @@ -138,6 +145,13 @@ SDL_Swap32(Uint32 x) __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); return result; } +#elif defined(__GNUC__) && defined(__aarch64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rev %w1, %w0": "=r"(x):"r"(x)); + return x; +} #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)