(libretro-common) Simplify compat_ctz

This commit is contained in:
twinaphex 2016-08-19 20:18:04 +02:00
parent a27f042731
commit acf76f6a58

View File

@ -57,23 +57,17 @@ static INLINE unsigned compat_clz_u16(uint16_t val)
}
/* Count Trailing Zero */
static INLINE int compat_ctz(unsigned x)
{
#if defined(__GNUC__) && !defined(RARCH_CONSOLE)
static INLINE int compat_ctz(unsigned x)
{
return __builtin_ctz(x);
}
#elif _MSC_VER >= 1400
static INLINE int compat_ctz(unsigned x)
{
unsigned long r = 0;
_BitScanReverse((unsigned long*)&r, x);
return (int)r;
}
#else
/* Only checks at nibble granularity,
* because that's what we need. */
static INLINE int compat_ctz(unsigned x)
{
if (x & 0x000f)
return 0;
if (x & 0x00f0)
@ -83,8 +77,8 @@ static INLINE int compat_ctz(unsigned x)
if (x & 0xf000)
return 12;
return 16;
}
#endif
}
RETRO_END_DECLS