]> xenbits.xensource.com Git - xen.git/commitdiff
x86/gen-cpuid: Minor cleanup
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 10 May 2024 19:04:51 +0000 (20:04 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 20 May 2024 16:01:20 +0000 (17:01 +0100)
Rename INIT_FEATURE_NAMES to INIT_FEATURE_NAME_TO_VAL as we're about to gain a
inverse mapping of the same thing.

Use dict.items() unconditionally.  iteritems() is a marginal perf optimsiation
for Python2 only, and simply not worth the effort on a script this small.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
tools/libs/light/libxl_cpuid.c
xen/arch/x86/cpu-policy.c
xen/tools/gen-cpuid.py

index ce4f3c7095ba4314997d14414a2445916c82f1b6..063fe86eb72f914fc4b48fe79e248c003d023a34 100644 (file)
@@ -296,7 +296,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
 
         {NULL, 0, NA, CPUID_REG_INV, 0, 0}
     };
-    static const struct feature_name features[] = INIT_FEATURE_NAMES;
+    static const struct feature_name features[] = INIT_FEATURE_NAME_TO_VAL;
     /*
      * NB: if we switch to using a cpu_policy derived object instead of a
      * libxl_cpuid_policy_list we could get rid of the featureset -> cpuid leaf
index 99871b8e0e0530682c8dac735cfb3f587e3e8826..b96f4ee55cc4c77a4f73d07438c5379f45808f0d 100644 (file)
@@ -43,7 +43,7 @@ static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
 static const struct feature_name {
     const char *name;
     unsigned int bit;
-} feature_names[] __initconstrel = INIT_FEATURE_NAMES;
+} feature_names[] __initconstrel = INIT_FEATURE_NAME_TO_VAL;
 
 /*
  * Parse a list of cpuid feature names -> bool, calling the callback for any
index 380b9d973a67c9e8c11479d473288ef7ef619f02..79d7f5c8e1c94619b75ad9b4e6586f24d966474f 100755 (executable)
@@ -459,15 +459,10 @@ def write_results(state):
     state.output.write(
 """}
 
-#define INIT_FEATURE_NAMES { \\
+#define INIT_FEATURE_NAME_TO_VAL { \\
 """)
 
-    try:
-        _tmp = state.values.iteritems()
-    except AttributeError:
-        _tmp = state.values.items()
-
-    for name, bit in sorted(_tmp):
+    for name, bit in sorted(state.values.items()):
         state.output.write(
             '    { "%s", %sU },\\\n' % (name, bit)
             )