[Commits] SDL: SDL_endian.h: add SDL_Swap16 and SDL_Swap32 for Watcom/x86 ...

libsdl.org revision control commits-owner at libsdl.org
Fri Aug 18 13:37:31 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/0f1c85713294
changeset: 11315:0f1c85713294
user:      Ozkan Sezer <sezeroz at gmail.com>
date:      Thu Aug 17 21:32:00 2017 -0400
description:
SDL_endian.h: add SDL_Swap16 and SDL_Swap32 for Watcom/x86 as inline asm

Partially fixes Bugzilla #3758.

diffstat:

 include/SDL_endian.h |  21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diffs (38 lines):

diff -r d66e1e9ab531 -r 0f1c85713294 include/SDL_endian.h
--- a/include/SDL_endian.h	Thu Aug 17 21:30:29 2017 -0400
+++ b/include/SDL_endian.h	Thu Aug 17 21:32:00 2017 -0400
@@ -96,6 +96,12 @@
   __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
     return x;
 }
+#elif defined(__WATCOMC__) && defined(__386__)
+extern _inline Uint16 SDL_Swap16(Uint16);
+#pragma aux SDL_Swap16 = \
+  "xchg al, ah" \
+  parm   [ax]   \
+  modify [ax];
 #else
 SDL_FORCE_INLINE Uint16
 SDL_Swap16(Uint16 x)
@@ -136,6 +142,21 @@
   __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
     return x;
 }
+#elif defined(__WATCOMC__) && defined(__386__)
+extern _inline Uint32 SDL_Swap32(Uint32);
+#ifndef __SW_3 /* 486+ */
+#pragma aux SDL_Swap32 = \
+  "bswap eax"  \
+  parm   [eax] \
+  modify [eax];
+#else  /* 386-only */
+#pragma aux SDL_Swap32 = \
+  "xchg al, ah"  \
+  "ror  eax, 16" \
+  "xchg al, ah"  \
+  parm   [eax]   \
+  modify [eax];
+#endif
 #else
 SDL_FORCE_INLINE Uint32
 SDL_Swap32(Uint32 x)


More information about the commits mailing list