]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
x86: Consolidate cpuid_eax and cpuid_ecx definitions via a macro
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 23 Dec 2013 12:31:54 +0000 (13:31 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 26 Dec 2013 16:52:01 +0000 (17:52 +0100)
Only the register name varies, and we can save some lines of code with
the help of the preprocessor.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/x86/include/asm/processor.h

index 61f734a3e9615ac84bdcd19e4702e30507575e16..b9055e57fbdd63e77ac5b05e02141536defbd6f2 100644 (file)
@@ -149,21 +149,17 @@ static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx,
        __cpuid(eax, ebx, ecx, edx);
 }
 
-static inline unsigned int cpuid_eax(unsigned int op)
-{
-       unsigned int eax, ebx, ecx, edx;
-
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-       return eax;
+#define CPUID_REG(reg)                                         \
+static inline unsigned int cpuid_##reg(unsigned int op)                \
+{                                                              \
+       unsigned int eax, ebx, ecx, edx;                        \
+                                                               \
+       cpuid(op, &eax, &ebx, &ecx, &edx);                      \
+       return reg;                                             \
 }
 
-static inline unsigned int cpuid_ecx(unsigned int op)
-{
-       unsigned int eax, ebx, ecx, edx;
-
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-       return ecx;
-}
+CPUID_REG(eax)
+CPUID_REG(ecx)
 
 static inline unsigned long read_cr0(void)
 {