/* Copyright (c) 2018 ZAO "MCST". All rights reserved. */

#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
# error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."
#endif

#ifndef _LZCNTINTRIN_H_INCLUDED
#define _LZCNTINTRIN_H_INCLUDED

#ifndef __LZCNT__
# error "LZCNT instruction set not enabled"
#endif /* __LZCNT__ */

/* Define the default attributes for the functions in this file */
#define __DEFAULT_FUNCS_ATTRS __attribute__((/*__gnu_inline__,*/ __always_inline__, __artificial__))

__E2K_INLINE unsigned short __DEFAULT_FUNCS_ATTRS
__lzcnt16 (unsigned short __X)
{
  return __builtin_clzs (__X);
}

__E2K_INLINE unsigned int __DEFAULT_FUNCS_ATTRS
__lzcnt32 (unsigned int __X)
{
  return __builtin_clz (__X);
}

__E2K_INLINE unsigned int __DEFAULT_FUNCS_ATTRS
_lzcnt_u32 (unsigned int __X)
{
  return __builtin_clz (__X);
}

__E2K_INLINE unsigned long long __DEFAULT_FUNCS_ATTRS
__lzcnt64 (unsigned long long __X)
{
  return __builtin_clzll (__X);
}

__E2K_INLINE unsigned long long __DEFAULT_FUNCS_ATTRS
_lzcnt_u64 (unsigned long long __X)
{
  return __builtin_clzll (__X);
}

#undef __DEFAULT_FUNCS_ATTRS

#endif /* _LZCNTINTRIN_H_INCLUDED */
