Commit 188c7d6670fc69d01495ba791bd3d5c7d10c6824

Alexei Podtelezhnikov 2021-11-09T22:47:26

Additional `FT_MSB` macro definitions. Better macros for Windoes CE and ARM in general, based on !109 from metarutaiga. * include/freetype/internal/ftcalc.h [_MSC_VER] (FT_MSB): Updated.

diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h
index a0f6890..b28d4bf 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -372,9 +372,23 @@ FT_BEGIN_HEADER
 
 #endif
 
-#elif defined( _MSC_VER ) && ( _MSC_VER >= 1400 )
+#elif defined( _MSC_VER ) && _MSC_VER >= 1400
 
-#if FT_SIZEOF_INT == 4
+#if defined( _WIN32_WCE )
+
+#include <cmnintrin.h>
+#pragma intrinsic( _CountLeadingZeros )
+
+#define FT_MSB( x )  ( 31 - _CountLeadingZeros( x ) )
+
+#elif defined( _M_ARM64 ) || defined( _M_ARM )
+
+#include <intrin.h>
+#pragma intrinsic( _CountLeadingZeros )
+
+#define FT_MSB( x )  ( 31 - _CountLeadingZeros( x ) )
+
+#elif defined( _M_IX86 ) || defined( _M_AMD64 ) || defined( _M_IA64 )
 
 #include <intrin.h>
 #pragma intrinsic( _BitScanReverse )
@@ -390,7 +404,7 @@ FT_BEGIN_HEADER
     return (FT_Int32)where;
   }
 
-#define FT_MSB( x )  ( FT_MSB_i386( x ) )
+#define FT_MSB( x )  FT_MSB_i386( x )
 
 #endif