removed a useless restriction from Watcom version of SDL_Swap32()

also did a little whitespace tidy-up.
This commit is contained in:
Ozkan Sezer 2021-02-24 20:03:50 +03:00
parent b8d2185277
commit 55a385a333
1 changed files with 21 additions and 33 deletions

View File

@ -157,9 +157,9 @@ SDL_Swap32(Uint32 x)
{ {
Uint32 result; Uint32 result;
__asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); __asm__("rlwimi %0,%2,24,16,23": "=&r"(result): "0" (x>>24), "r"(x));
__asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); __asm__("rlwimi %0,%2,8,8,15" : "=&r"(result): "0" (result), "r"(x));
__asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x));
return result; return result;
} }
#elif defined(__GNUC__) && defined(__aarch64__) #elif defined(__GNUC__) && defined(__aarch64__)
@ -178,19 +178,10 @@ SDL_Swap32(Uint32 x)
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint32 SDL_Swap32(Uint32); extern _inline Uint32 SDL_Swap32(Uint32);
#ifndef __SW_3 /* 486+ */
#pragma aux SDL_Swap32 = \ #pragma aux SDL_Swap32 = \
"bswap eax" \ "bswap eax" \
parm [eax] \ parm [eax] \
modify [eax]; modify [eax];
#else /* 386-only */
#pragma aux SDL_Swap32 = \
"xchg al, ah" \
"ror eax, 16" \
"xchg al, ah" \
parm [eax] \
modify [eax];
#endif
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_ulong)
#define SDL_Swap32(x) _byteswap_ulong(x) #define SDL_Swap32(x) _byteswap_ulong(x)
@ -211,18 +202,16 @@ SDL_Swap32(Uint32 x)
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
union union {
{ struct {
struct
{
Uint32 a, b; Uint32 a, b;
} s; } s;
Uint64 u; Uint64 u;
} v; } v;
v.u = x; v.u = x;
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
"1"(v.s. : "=r"(v.s.a), "=r"(v.s.b)
b)); : "0" (v.s.a), "1"(v.s.b));
return v.u; return v.u;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__GNUC__) && defined(__x86_64__)
@ -264,8 +253,7 @@ SDL_Swap64(Uint64 x)
SDL_FORCE_INLINE float SDL_FORCE_INLINE float
SDL_SwapFloat(float x) SDL_SwapFloat(float x)
{ {
union union {
{
float f; float f;
Uint32 ui32; Uint32 ui32;
} swapper; } swapper;
@ -281,22 +269,22 @@ SDL_SwapFloat(float x)
*/ */
/* @{ */ /* @{ */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SDL_SwapLE16(X) (X) #define SDL_SwapLE16(X) (X)
#define SDL_SwapLE32(X) (X) #define SDL_SwapLE32(X) (X)
#define SDL_SwapLE64(X) (X) #define SDL_SwapLE64(X) (X)
#define SDL_SwapFloatLE(X) (X) #define SDL_SwapFloatLE(X) (X)
#define SDL_SwapBE16(X) SDL_Swap16(X) #define SDL_SwapBE16(X) SDL_Swap16(X)
#define SDL_SwapBE32(X) SDL_Swap32(X) #define SDL_SwapBE32(X) SDL_Swap32(X)
#define SDL_SwapBE64(X) SDL_Swap64(X) #define SDL_SwapBE64(X) SDL_Swap64(X)
#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) #define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
#else #else
#define SDL_SwapLE16(X) SDL_Swap16(X) #define SDL_SwapLE16(X) SDL_Swap16(X)
#define SDL_SwapLE32(X) SDL_Swap32(X) #define SDL_SwapLE32(X) SDL_Swap32(X)
#define SDL_SwapLE64(X) SDL_Swap64(X) #define SDL_SwapLE64(X) SDL_Swap64(X)
#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) #define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
#define SDL_SwapBE16(X) (X) #define SDL_SwapBE16(X) (X)
#define SDL_SwapBE32(X) (X) #define SDL_SwapBE32(X) (X)
#define SDL_SwapBE64(X) (X) #define SDL_SwapBE64(X) (X)
#define SDL_SwapFloatBE(X) (X) #define SDL_SwapFloatBE(X) (X)
#endif #endif
/* @} *//* Swap to native */ /* @} *//* Swap to native */