Turn FT_MSB into a macro when using gcc builtins. * src/base/ftcalc.c, include/internal/ftcalc.h: Updated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
diff --git a/ChangeLog b/ChangeLog
index b6c5228..32aa534 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-13 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ Turn FT_MSB into a macro when using gcc builtins.
+
+ * src/base/ftcalc.c, include/internal/ftcalc.h: Updated.
+
2014-08-12 Alexei Podtelezhnikov <apodtele@gmail.com>
[base] Avoid undefined FT_MSB in `BBox_Cubic_Check'.
diff --git a/include/internal/ftcalc.h b/include/internal/ftcalc.h
index ff4e611..b3cd618 100644
--- a/include/internal/ftcalc.h
+++ b/include/internal/ftcalc.h
@@ -261,22 +261,6 @@ FT_BEGIN_HEADER
#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 */
@@ -367,9 +351,32 @@ FT_BEGIN_HEADER
/*
* Return the most significant bit index.
*/
+
+#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
+#if defined( __GNUC__ )
+#if ( __GNUC__ > 3 ) || ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 4 ) )
+
+#if FT_SIZEOF_INT == 4
+
+#define FT_MSB( x ) ( 31 - __builtin_clz( x ) )
+
+#elif FT_SIZEOF_LONG == 4
+
+#define FT_MSB( x ) ( 31 - __builtin_clzl( x ) )
+
+#endif
+
+#endif
+#endif /* __GNUC__ */
+#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
+
+#ifndef FT_MSB
+
FT_BASE( FT_Int )
FT_MSB( FT_UInt32 z );
+#endif
+
/*
* Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index d12a981..9188e2c 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -100,16 +100,11 @@
: -((-a) & ~0xFFFFL );
}
+#ifndef FT_MSB
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' */
@@ -140,10 +135,10 @@
}
return shift;
-
-#endif /* FT_MSB_BUILTIN */
}
+#endif /* !FT_MSB */
+
/* documentation is in ftcalc.h */