shithub: freetype+ttf2subf

Download patch

ref: 177982e933ed6f2ab96163e14f4267f8abe89efd
parent: 71330ceb50634f566abcbcdd4e21bdb962623b3d
author: Alexei Podtelezhnikov <[email protected]>
date: Tue Jul 15 19:54:34 EDT 2014

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

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-07-15  Alexei Podtelezhnikov  <[email protected]>
 
+	* src/base/ftcalc.c (FT_MSB): Utilize gcc builtins. 
+
+2014-07-15  Alexei Podtelezhnikov  <[email protected]>
+
 	[base] Move assembler code back in the source file.
 
 	FT_MulFix assembler used to reside in ftcalc.c before f47d263f1b.
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -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 */
   }