mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-27 13:16:14 +00:00
Add compat_clz_u16
This commit is contained in:
parent
6fc943228e
commit
53701a565f
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user