]> git.ozlabs.org Git - ccan/blobdiff - ccan/cpuid/cpuid.c
cpuid: fix for MSVC in cpuid_is_supported()
[ccan] / ccan / cpuid / cpuid.c
index 57883e2bd0982b17fccdeaf34fd5da945c1134ea..df9b4aafc530268f96280e9bf52260c7477765dc 100644 (file)
@@ -160,8 +160,8 @@ bool cpuid_is_supported(void)
                pushfd
                pop eax
                xor eax, ecx
-               shr eax, 0x21
-               and eax, 0x1
+               shr eax, 21
+               and eax, 1
                push ecx
                popfd
 
@@ -309,10 +309,20 @@ void cpuid(cpuid_t info, uint32_t *buf)
                        buf[2] = ecx;
                        break;
                case CPU_PROCINFO_AND_FEATUREBITS:
-                       buf[0] = eax;   /* The so called "signature" of the CPU.  */
-                       buf[1] = edx;   /* Feature flags #1.  */
-                       buf[2] = ecx;   /* Feature flags #2.  */
-                       buf[3] = ebx;   /* Additional feature information.  */
+                       buf[0] = (eax & 0x0F);          /* Stepping  */
+                       buf[1] = (eax >> 4)  & 0x0F;    /* Model  */
+                       buf[2] = (eax >> 8)  & 0x0F;    /* Family  */
+                       buf[3] = (eax >> 16) & 0x0F;    /* Extended Model.  */
+                       buf[4] = (eax >> 24) & 0x0F;    /* Extended Family.  */
+
+                       buf[5] = edx;                   /* Feature flags #1.  */
+                       buf[6] = ecx;                   /* Feature flags #2.  */
+
+                       /* Additional Feature information.  */
+                       buf[7] = ebx & 0xFF;
+                       buf[8] = (ebx >> 8) & 0xFF;
+                       buf[9] = (ebx >> 16) & 0xFF;
+                       buf[10] = (ebx >> 24) & 0xFF;
                        break;
                case CPU_CACHE_AND_TLBD_INFO:
                        buf[0] = eax;