SDL_endian.h: add SDL_Swap16 and SDL_Swap32 for Watcom/x86 as inline asm
authorOzkan Sezer <sezeroz@gmail.com>
Thu, 17 Aug 2017 21:32:00 -0400
changeset 113150f1c85713294
parent 11314 d66e1e9ab531
child 11316 76abc6e1eb4b
SDL_endian.h: add SDL_Swap16 and SDL_Swap32 for Watcom/x86 as inline asm

Partially fixes Bugzilla #3758.
include/SDL_endian.h
     1.1 --- a/include/SDL_endian.h	Thu Aug 17 21:30:29 2017 -0400
     1.2 +++ b/include/SDL_endian.h	Thu Aug 17 21:32:00 2017 -0400
     1.3 @@ -96,6 +96,12 @@
     1.4    __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
     1.5      return x;
     1.6  }
     1.7 +#elif defined(__WATCOMC__) && defined(__386__)
     1.8 +extern _inline Uint16 SDL_Swap16(Uint16);
     1.9 +#pragma aux SDL_Swap16 = \
    1.10 +  "xchg al, ah" \
    1.11 +  parm   [ax]   \
    1.12 +  modify [ax];
    1.13  #else
    1.14  SDL_FORCE_INLINE Uint16
    1.15  SDL_Swap16(Uint16 x)
    1.16 @@ -136,6 +142,21 @@
    1.17    __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
    1.18      return x;
    1.19  }
    1.20 +#elif defined(__WATCOMC__) && defined(__386__)
    1.21 +extern _inline Uint32 SDL_Swap32(Uint32);
    1.22 +#ifndef __SW_3 /* 486+ */
    1.23 +#pragma aux SDL_Swap32 = \
    1.24 +  "bswap eax"  \
    1.25 +  parm   [eax] \
    1.26 +  modify [eax];
    1.27 +#else  /* 386-only */
    1.28 +#pragma aux SDL_Swap32 = \
    1.29 +  "xchg al, ah"  \
    1.30 +  "ror  eax, 16" \
    1.31 +  "xchg al, ah"  \
    1.32 +  parm   [eax]   \
    1.33 +  modify [eax];
    1.34 +#endif
    1.35  #else
    1.36  SDL_FORCE_INLINE Uint32
    1.37  SDL_Swap32(Uint32 x)