Unverified Commit 3ee1c472 authored by Viktor Oreshkin's avatar Viktor Oreshkin Committed by GitHub

Use GCC's <cpuid.h> instead of manual inline asm

Merge pull request #54 from dfedin/master: Fix for crash on 32-bit system in cpuid code
parents 129ad2f9 55e30e09
...@@ -19,8 +19,11 @@ ...@@ -19,8 +19,11 @@
*/ */
#include <assert.h> #include <assert.h>
#include <cpuid.h>
#include "cpuid.h" #include "cpuid.h"
#define CPUID_MAGIC 0x280147b8 #define CPUID_MAGIC 0x280147b8
kdb_cpuid_t *kdb_cpuid (void) { kdb_cpuid_t *kdb_cpuid (void) {
...@@ -30,17 +33,7 @@ kdb_cpuid_t *kdb_cpuid (void) { ...@@ -30,17 +33,7 @@ kdb_cpuid_t *kdb_cpuid (void) {
return &cached; return &cached;
} }
int a; int a;
#if ( __GNUC__ < 5 ) && defined( __i386__ ) && defined( __PIC__ ) assert(__get_cpuid(1, &a, &cached.ebx, &cached.ecx, &cached.edx) != 0);
asm volatile ("cpuid\n\t"
: "=a" (a), "=D" (cached.ebx) , "=c" (cached.ecx), "=d" (cached.edx)
: "0" (1)
);
#else
asm volatile ("cpuid\n\t"
: "=a" (a), "=b" (cached.ebx) , "=c" (cached.ecx), "=d" (cached.edx)
: "0" (1)
);
#endif
cached.magic = CPUID_MAGIC; cached.magic = CPUID_MAGIC;
return &cached; return &cached;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment