Add compat_clz_u16

This commit is contained in:
twinaphex 2016-06-07 04:15:27 +02:00
parent 6fc943228e
commit 53701a565f

View File

@ -23,14 +23,34 @@
#ifndef __LIBRETRO_SDK_COMPAT_INTRINSICS_H
#define __LIBRETRO_SDK_COMPAT_INTRINSICS_H
#include <string.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <retro_common_api.h>
#include <retro_inline.h>
RETRO_BEGIN_DECLS
/* Count Leading Zero, unsigned 16bit input value */
static INLINE unsigned compat_clz_u16(uint16_t val)
{
#ifdef __GNUC__
return __builtin_clz(val << 16 | 0x8000);
#else
unsigned ret = 0;
while(!(val & 0x8000) && ret < 16)
{
val <<= 1;
ret++;
}
return ret;
#endif
}
/* Count Trailing Zero */
#if defined(__GNUC__)
static INLINE int compat_ctz(unsigned x)
{