diff mbox series

[2/2] libxl: allow building with old gcc again

Message ID 550a2b3d-ed15-6035-623d-8725edb40b2d@suse.com (mailing list archive)
State New, archived
Headers show
Series libxl: build fixes for recent CPUID work | expand

Commit Message

Jan Beulich Aug. 3, 2023, 2:15 p.m. UTC
We can't use initializers of unnamed struct/union members just yet.

Fixes: d638fe233cb3 ("libxl: use the cpuid feature names from cpufeatureset.h")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

--- a/tools/libs/light/libxl_cpuid.c
+++ b/tools/libs/light/libxl_cpuid.c
@@ -316,12 +316,16 @@  int libxl_cpuid_parse_config(libxl_cpuid
                 uint32_t index;
                 unsigned int reg;
             } msr;
-        };
+        } u;
     } feature_to_policy[] = {
 #define CPUID_ENTRY(l, s, r) \
-    { .type = FEAT_CPUID, .cpuid.leaf = l, .cpuid.subleaf = s, .cpuid.reg = r }
+    { .type = FEAT_CPUID, \
+      .u = { .cpuid.leaf = l, .cpuid.subleaf = s, .cpuid.reg = r } \
+    }
 #define MSR_ENTRY(i, r) \
-    { .type = FEAT_MSR, .msr.index = i, .msr.reg = r }
+    { .type = FEAT_MSR, \
+      .u = { .msr.index = i, .msr.reg = r } \
+    }
         CPUID_ENTRY(0x00000001, NA, CPUID_REG_EDX),
         CPUID_ENTRY(0x00000001, NA, CPUID_REG_ECX),
         CPUID_ENTRY(0x80000001, NA, CPUID_REG_EDX),
@@ -380,9 +384,9 @@  int libxl_cpuid_parse_config(libxl_cpuid
         struct cpuid_flags f;
 
         f.name = feat->name;
-        f.leaf = feature_to_policy[feat->bit / 32].cpuid.leaf;
-        f.subleaf = feature_to_policy[feat->bit / 32].cpuid.subleaf;
-        f.reg = feature_to_policy[feat->bit / 32].cpuid.reg;
+        f.leaf = feature_to_policy[feat->bit / 32].u.cpuid.leaf;
+        f.subleaf = feature_to_policy[feat->bit / 32].u.cpuid.subleaf;
+        f.reg = feature_to_policy[feat->bit / 32].u.cpuid.reg;
         f.bit = feat->bit % 32;
         f.length = 1;
 
@@ -393,10 +397,10 @@  int libxl_cpuid_parse_config(libxl_cpuid
     {
         unsigned int bit = feat->bit % 32;
 
-        if (feature_to_policy[feat->bit / 32].msr.reg == CPUID_REG_EDX)
+        if (feature_to_policy[feat->bit / 32].u.msr.reg == CPUID_REG_EDX)
             bit += 32;
 
-        return msr_add(policy, feature_to_policy[feat->bit / 32].msr.index,
+        return msr_add(policy, feature_to_policy[feat->bit / 32].u.msr.index,
                        bit, val);
     }
     }