mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-16 23:48:51 +00:00
(libretro-common) Simplify compat_ctz
This commit is contained in:
parent
a27f042731
commit
acf76f6a58
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user