* src/base/ftcalc.c (FT_MSB): Utilize gcc builtins.

This commit is contained in:
Alexei Podtelezhnikov 2014-07-15 23:54:34 -04:00
parent 71330ceb50
commit 177982e933
2 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2014-07-15 Alexei Podtelezhnikov <apodtele@gmail.com>
* src/base/ftcalc.c (FT_MSB): Utilize gcc builtins.
2014-07-15 Alexei Podtelezhnikov <apodtele@gmail.com>
[base] Move assembler code back in the source file.

View File

@ -243,6 +243,22 @@
#endif /* __GNUC__ && __x86_64__ */
#if defined( __GNUC__ )
#if ( __GNUC__ > 3 ) || ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 4 ) )
#if FT_SIZEOF_INT == 4
#define FT_MSB_BUILTIN( x ) ( 31 - __builtin_clz( x ) )
#elif FT_SIZEOF_LONG == 4
#define FT_MSB_BUILTIN( x ) ( 31 - __builtin_clzl( x ) )
#endif
#endif
#endif /* __GNUC__ */
#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
@ -316,6 +332,12 @@
FT_BASE_DEF ( FT_Int )
FT_MSB( FT_UInt32 z )
{
#ifdef FT_MSB_BUILTIN
return FT_MSB_BUILTIN( z );
#else
FT_Int shift = 0;
/* determine msb bit index in `shift' */
@ -346,6 +368,8 @@
}
return shift;
#endif /* FT_MSB_BUILTIN */
}