simplify Watcom implementation of SDL_MostSignificantBitIndex32()

This commit is contained in:
Ozkan Sezer 2021-01-04 03:00:10 +03:00
parent ae18109a92
commit f414a43632
1 changed files with 3 additions and 4 deletions

View File

@ -48,10 +48,9 @@ extern "C" {
* \return Index of the most significant bit, or -1 if the value is 0. * \return Index of the most significant bit, or -1 if the value is 0.
*/ */
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
extern _inline int _SDL_clz_watcom (Uint32); extern _inline int _SDL_bsr_watcom (Uint32);
#pragma aux _SDL_clz_watcom = \ #pragma aux _SDL_bsr_watcom = \
"bsr eax, eax" \ "bsr eax, eax" \
"xor eax, 31" \
parm [eax] nomemory \ parm [eax] nomemory \
value [eax] \ value [eax] \
modify exact [eax] nomemory; modify exact [eax] nomemory;
@ -72,7 +71,7 @@ SDL_MostSignificantBitIndex32(Uint32 x)
if (x == 0) { if (x == 0) {
return -1; return -1;
} }
return 31 - _SDL_clz_watcom(x); return _SDL_bsr_watcom(x);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
unsigned long index; unsigned long index;
if (_BitScanReverse(&index, x)) { if (_BitScanReverse(&index, x)) {