]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
cpuid for msvc
authorMat Berchtold <mberchtold@gmail.com>
Thu, 29 Oct 2015 14:38:02 +0000 (15:38 +0100)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 2 Nov 2015 12:13:22 +0000 (13:13 +0100)
arch/x86/x86.c

index 299ddff9bd7f38a2d604ab1ef7c4877e44243b16..8ab12e31494476545b1267b50a3c36a60247b59b 100644 (file)
@@ -14,6 +14,22 @@ ZLIB_INTERNAL int x86_cpu_has_sse2;
 ZLIB_INTERNAL int x86_cpu_has_sse42;
 ZLIB_INTERNAL int x86_cpu_has_pclmulqdq;
 
+#ifdef _MSC_VER
+#include <intrin.h>\r
+#define CPU_PROCINFO_AND_FEATUREBITS 1\r
+\r
+void ZLIB_INTERNAL x86_check_features(void) {\r
+       unsigned int registers[4];\r
+       __cpuid(registers, CPU_PROCINFO_AND_FEATUREBITS);\r
+\r
+       unsigned int ecx = registers[2];\r
+       unsigned int edx = registers[3];\r
+\r
+       x86_cpu_has_sse2 = edx & 0x4000000;
+       x86_cpu_has_sse42 = ecx & 0x100000;
+       x86_cpu_has_pclmulqdq = ecx & 0x2;\r
+}
+#else
 void ZLIB_INTERNAL x86_check_features(void) {
     unsigned eax, ebx, ecx, edx;
 
@@ -30,8 +46,8 @@ void ZLIB_INTERNAL x86_check_features(void) {
     : "+a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
 #endif
     );
-
     x86_cpu_has_sse2 = edx & 0x4000000;
     x86_cpu_has_sse42 = ecx & 0x100000;
     x86_cpu_has_pclmulqdq = ecx & 0x2;
 }
+#endif
\ No newline at end of file