qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 04/17 v3] target-i386: add x86_cpu_vendor_words2str(


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH 04/17 v3] target-i386: add x86_cpu_vendor_words2str()
Date: Mon, 14 Jan 2013 19:33:47 +0100

Make for() cycle reusable for the next patch

Signed-off-by: Igor Mammedov <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
---
  v5:
   - style fix: added extra space to align arguments
        Spotted-By: Eduardo Habkost <address@hidden>
        Spotted-By: Andreas Färber <address@hidden>
  v4:
   - rename x86cpu_vendor_words2str() to x86_cpu_vendor_words2str()
        Suggested-By: Andreas Färber <address@hidden>
  v3:
   -replace e[bcd]x arguments naming with vendor[123]
   -fix/swap vendor2 and vendor3 order
        Spotted-By: Eduardo Habkost <address@hidden>
  v2:
   -place x86cpu_vendor_words2str() a bit earlier, before feature
    arrays to avoid compile error when vendor property is converted
    static property.
---
 target-i386/cpu.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 333745b..e9aebda 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -45,6 +45,18 @@
 #include "hw/apic_internal.h"
 #endif
 
+static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
+                                     uint32_t vendor2, uint32_t vendor3)
+{
+    int i;
+    for (i = 0; i < 4; i++) {
+        dst[i] = vendor1 >> (8 * i);
+        dst[i + 4] = vendor2 >> (8 * i);
+        dst[i + 8] = vendor3 >> (8 * i);
+    }
+    dst[CPUID_VENDOR_SZ] = '\0';
+}
+
 /* feature flags taken from "Intel Processor Identification and the CPUID
  * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
  * between feature naming conventions, aliases may be added.
@@ -1213,15 +1225,10 @@ static char *x86_cpuid_get_vendor(Object *obj, Error 
**errp)
     X86CPU *cpu = X86_CPU(obj);
     CPUX86State *env = &cpu->env;
     char *value;
-    int i;
 
     value = (char *)g_malloc(CPUID_VENDOR_SZ + 1);
-    for (i = 0; i < 4; i++) {
-        value[i    ] = env->cpuid_vendor1 >> (8 * i);
-        value[i + 4] = env->cpuid_vendor2 >> (8 * i);
-        value[i + 8] = env->cpuid_vendor3 >> (8 * i);
-    }
-    value[CPUID_VENDOR_SZ] = '\0';
+    x86_cpu_vendor_words2str(value, env->cpuid_vendor1, env->cpuid_vendor2,
+                             env->cpuid_vendor3);
     return value;
 }
 
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]