qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, imammedo@redhat.com, ehabkost@redhat.com,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH qom-cpu 2/4] target-i386: Drop redundant list of CPU definitions
Date: Sun,  9 Dec 2012 20:45:51 +0100	[thread overview]
Message-ID: <1355082353-322-3-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1355082353-322-1-git-send-email-afaerber@suse.de>

Since we are no longer parsing cpudefs from config files, only the array
of built-in definitions remains.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-i386/cpu.c |   37 ++++++++++++++-----------------------
 1 Datei geändert, 14 Zeilen hinzugefügt(+), 23 Zeilen entfernt(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a46faa2..e265317 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -330,11 +330,7 @@ typedef struct x86_def_t {
 #define TCG_SVM_FEATURES 0
 #define TCG_7_0_EBX_FEATURES (CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_SMAP)
 
-/* maintains list of cpu model definitions
- */
-static x86_def_t *x86_defs = {NULL};
-
-/* built-in cpu model definitions (deprecated)
+/* built-in cpu model definitions
  */
 static x86_def_t builtin_x86_defs[] = {
     {
@@ -1210,20 +1206,17 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
 
 static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
 {
-    x86_def_t *def;
+    int i;
 
-    for (def = x86_defs; def; def = def->next) {
-        if (name && !strcmp(name, def->name)) {
-            break;
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
+        x86_def_t *def = &builtin_x86_defs[i];
+        if (strcmp(name, def->name) == 0) {
+            memcpy(x86_cpu_def, def, sizeof(*def));
+            return 0;
         }
     }
-    if (!def) {
-        return -1;
-    } else {
-        memcpy(x86_cpu_def, def, sizeof(*def));
-    }
 
-    return 0;
+    return -1;
 }
 
 /* Parse "+feature,-feature,feature=foo" CPU feature string
@@ -1418,10 +1411,11 @@ static void listflags(char *buf, int bufsize, uint32_t fbits,
 /* generate CPU information. */
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
-    x86_def_t *def;
+    int i;
     char buf[256];
 
-    for (def = x86_defs; def; def = def->next) {
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
+        x86_def_t *def = &builtin_x86_defs[i];
         snprintf(buf, sizeof(buf), "%s", def->name);
         (*cpu_fprintf)(f, "x86 %16s  %-48s\n", buf, def->model_id);
     }
@@ -1442,14 +1436,14 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
 {
     CpuDefinitionInfoList *cpu_list = NULL;
-    x86_def_t *def;
+    int i;
 
-    for (def = x86_defs; def; def = def->next) {
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
         CpuDefinitionInfoList *entry;
         CpuDefinitionInfo *info;
 
         info = g_malloc0(sizeof(*info));
-        info->name = g_strdup(def->name);
+        info->name = g_strdup(builtin_x86_defs[i].name);
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;
@@ -1598,7 +1592,6 @@ void x86_cpudef_setup(void)
 
     for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); ++i) {
         x86_def_t *def = &builtin_x86_defs[i];
-        def->next = x86_defs;
 
         /* Look for specific "cpudef" models that */
         /* have the QEMU version in .model_id */
@@ -1611,8 +1604,6 @@ void x86_cpudef_setup(void)
                 break;
             }
         }
-
-        x86_defs = def;
     }
 }
 
-- 
1.7.10.4

  parent reply	other threads:[~2012-12-09 19:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 18:32 [Qemu-devel] [PATCH] finally kill cpudef config section support Eduardo Habkost
2012-12-04 18:41 ` Andreas Färber
2012-12-04 18:53   ` Eduardo Habkost
2012-12-08 17:54 ` Blue Swirl
2012-12-08 18:02   ` Andreas Färber
2012-12-08 20:00     ` Blue Swirl
2012-12-09 19:13       ` Andreas Färber
2012-12-09 20:46         ` Blue Swirl
2012-12-10  0:13           ` Andreas Färber
2012-12-12 13:03             ` Eduardo Habkost
2012-12-10 18:03     ` Eduardo Habkost
2012-12-09 19:45 ` [Qemu-devel] [PATCH qom-cpu 0/4] target-i386: Finish killing cpudef support Andreas Färber
2012-12-09 19:45   ` [Qemu-devel] [PATCH qom-cpu 1/4] target-i386: Inline -cpu host check into cpu_x86_register() Andreas Färber
2012-12-10 12:46     ` Eduardo Habkost
2012-12-10 18:55       ` Igor Mammedov
2012-12-10 23:21         ` Andreas Färber
2012-12-10 23:33           ` Eduardo Habkost
2012-12-09 19:45   ` Andreas Färber [this message]
2012-12-10 18:22     ` [Qemu-devel] [PATCH qom-cpu 2/4] target-i386: Drop redundant list of CPU definitions Eduardo Habkost
2012-12-09 19:45   ` [Qemu-devel] [PATCH qom-cpu 3/4] Really finally kill cpudef config section support Andreas Färber
2012-12-10 18:09     ` Eduardo Habkost
2012-12-10 23:12       ` Andreas Färber
2012-12-10 23:53         ` Eduardo Habkost
2012-12-11  8:41           ` Wenchao Xia
2012-12-09 19:45   ` [Qemu-devel] [PATCH qom-cpu 4/4] MAINTAINERS: Include X86CPU in CPU maintenance area Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355082353-322-3-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=blauwirbel@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).