Compile fix: Do not rely on __cpuidex() for msvc2008
authorJan-Arve Saether <jan-arve.saether@nokia.com>
Wed, 16 May 2012 12:34:14 +0000 (14:34 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 18 May 2012 23:45:04 +0000 (01:45 +0200)
Since its hard to detect if __cpuidex() is actually available at
compile time, we'll add a function overload that will be chosen if the
intrinsic __cpuidex() is not available.

Note that the QtXgetbvHack that was used for _xgetbv did not really
work (MS compiler will bail out because of ambiguous overloads if the
intrinsic _xgetbv existed).

Therefore, we apply the same workaround for _xgetbv.

Change-Id: Iee3bf8bc6352ba0861b05d779f1f001d4eb013ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qsimd.cpp

index ac21e5b..821de8d 100644 (file)
@@ -212,6 +212,10 @@ static void cpuidFeatures01(uint &ecx, uint &edx)
 #endif
 }
 
+#ifdef Q_OS_WIN
+inline void __cpuidex(int info[4], int, __int64) { memset(info, 0, 4*sizeof(int));}
+#endif
+
 static void cpuidFeatures07_00(uint &ebx)
 {
 #if defined(Q_CC_GNU)
@@ -231,10 +235,7 @@ static void cpuidFeatures07_00(uint &ebx)
 }
 
 #ifdef Q_OS_WIN
-namespace QtXgetbvHack {
-    inline quint64 _xgetbv(int) { return 0; }
-}
-using namespace QtXgetbvHack;
+inline quint64 _xgetbv(__int64) { return 0; }
 #endif
 
 static void xgetbv(int in, uint &eax, uint &edx)