Skip to contentSkip to conversation

qapi: Fix compilation failure on MIPS

PATCH Applied Eric Blake 4 participants 6 messages Feb 2, 2016

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 qapi: Fix compilation failure on MIPS

Commit 86f4b687 broke compilation on MIPS, which has a preprocessor pollution of '#define mips 1'. Treat it the same way as we do for the pollution with 'unix', so that QMP remains backwards compatible and only the C code needs to use the alternative 'q_mips' spelling.

---
 scripts/qapi.py | 2 +-
 cpus.c          | 4 ++--
 hmp.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
scripts/qapi.py +1 -1
index d199222..7f114c4 100644
@@ -1482,7 +1482,7 @@ def c_name(name, protect=True):
                      'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not',
                      'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'])
     # namespace pollution:
-    polluted_words = set(['unix', 'errno'])
+    polluted_words = set(['unix', 'errno', 'mips'])
     name = name.translate(c_name_trans)
     if protect and (name in c89_words | c99_words | c11_words | gcc_words
                     | cpp_words | polluted_words):
cpus.c +2 -2
index 882b618..c8a2317 100644
@@ -1581,8 +1581,8 @@ CpuInfoList *qmp_query_cpus(Error **errp)
         info->value->u.sparc->npc = env->npc;
 #elif defined(TARGET_MIPS)
         info->value->arch = CPU_INFO_ARCH_MIPS;
-        info->value->u.mips = g_new0(CpuInfoMIPS, 1);
-        info->value->u.mips->PC = env->active_tc.PC;
+        info->value->u.q_mips = g_new0(CpuInfoMIPS, 1);
+        info->value->u.q_mips->PC = env->active_tc.PC;
 #elif defined(TARGET_TRICORE)
         info->value->arch = CPU_INFO_ARCH_TRICORE;
         info->value->u.tricore = g_new0(CpuInfoTricore, 1);
hmp.c +1 -1
index a4b74df..ef98344 100644
@@ -322,7 +322,7 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
             monitor_printf(mon, " npc=0x%016" PRIx64, cpu->value->u.sparc->npc);
             break;
         case CPU_INFO_ARCH_MIPS:
-            monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.mips->PC);
+            monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.q_mips->PC);
             break;
         case CPU_INFO_ARCH_TRICORE:
             monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore->PC);
Signature · 1 line
2.5.0
Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · Eric Blake

Commit 86f4b687 broke compilation on MIPS, which has a preprocessor pollution of '#define mips 1'. Treat it the same way as we do for the pollution with 'unix', so that QMP remains backwards compatible and only the C code needs to use the alternative 'q_mips' spelling.

Thanks, that fixes the build for me.

Cheers
James

Quoted 50 lines
---
 scripts/qapi.py | 2 +-
 cpus.c          | 4 ++--
 hmp.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
scripts/qapi.py +1 -1
index d199222..7f114c4 100644
@@ -1482,7 +1482,7 @@ def c_name(name, protect=True):
                      'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not',
                      'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'])
     # namespace pollution:
-    polluted_words = set(['unix', 'errno'])
+    polluted_words = set(['unix', 'errno', 'mips'])
     name = name.translate(c_name_trans)
     if protect and (name in c89_words | c99_words | c11_words | gcc_words
                     | cpp_words | polluted_words):
cpus.c +2 -2
index 882b618..c8a2317 100644
@@ -1581,8 +1581,8 @@ CpuInfoList *qmp_query_cpus(Error **errp)
         info->value->u.sparc->npc = env->npc;
 #elif defined(TARGET_MIPS)
         info->value->arch = CPU_INFO_ARCH_MIPS;
-        info->value->u.mips = g_new0(CpuInfoMIPS, 1);
-        info->value->u.mips->PC = env->active_tc.PC;
+        info->value->u.q_mips = g_new0(CpuInfoMIPS, 1);
+        info->value->u.q_mips->PC = env->active_tc.PC;
 #elif defined(TARGET_TRICORE)
         info->value->arch = CPU_INFO_ARCH_TRICORE;
         info->value->u.tricore = g_new0(CpuInfoTricore, 1);
hmp.c +1 -1
index a4b74df..ef98344 100644
@@ -322,7 +322,7 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
             monitor_printf(mon, " npc=0x%016" PRIx64, cpu->value->u.sparc->npc);
             break;
         case CPU_INFO_ARCH_MIPS:
-            monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.mips->PC);
+            monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.q_mips->PC);
             break;
         case CPU_INFO_ARCH_TRICORE:
             monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore->PC);
Signature · 1 line
2.5.0
#2 lore raw
In reply to Eric Blake
Quoted 7 lines · Eric Blake

Commit 86f4b687 broke compilation on MIPS, which has a preprocessor pollution of '#define mips 1'. Treat it the same way as we do for the pollution with 'unix', so that QMP remains backwards compatible and only the C code needs to use the alternative 'q_mips' spelling.

Applied to qapi-next, thanks!

#3 lore raw
In reply to Eric Blake
Quoted 18 lines · Eric Blake

Commit 86f4b687 broke compilation on MIPS, which has a preprocessor pollution of '#define mips 1'. Treat it the same way as we do for the pollution with 'unix', so that QMP remains backwards compatible and only the C code needs to use the alternative 'q_mips' spelling.

---
 scripts/qapi.py | 2 +-
 cpus.c          | 4 ++--
 hmp.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
scripts/qapi.py +0 -0
index d199222..7f114c4 100644

scripts/qapi.py def c_name(name, protect=True): · line 1488

Quoted 8 lines
scripts/qapi.py +1 -1
@@ -1482,7 +1482,7 @@ def c_name(name, protect=True):
                      'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not',
                      'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'])
     # namespace pollution:
-    polluted_words = set(['unix', 'errno'])
+    polluted_words = set(['unix', 'errno', 'mips'])
     name = name.translate(c_name_trans)
     if protect and (name in c89_words | c99_words | c11_words | gcc_words
                     | cpp_words | polluted_words):

Looking at commit 86f4b687 I think we also need to add 'sparc' to the polluted_words list (Solaris defines that). I would also be unsurprised to find that some PPC platforms define 'ppc'. (Tricore is probably new enough to have escaped this namespace pollution and we don't support it as a host CPU anyway.)

thanks
-- PMM

author
#4 lore raw
Quoted 17 lines · Peter Maydell
Quoted 10 lines · Eric Blake

Commit 86f4b687 broke compilation on MIPS, which has a preprocessor pollution of '#define mips 1'. Treat it the same way as we do for the pollution with 'unix', so that QMP remains backwards compatible and only the C code needs to use the alternative 'q_mips' spelling.

---

     # namespace pollution:

scripts/qapi.py def c_name(name, protect=True): · line 1488

Quoted 5 lines
scripts/qapi.py +1 -1
-    polluted_words = set(['unix', 'errno'])
+    polluted_words = set(['unix', 'errno', 'mips'])
     name = name.translate(c_name_trans)
     if protect and (name in c89_words | c99_words | c11_words | gcc_words
                     | cpp_words | polluted_words):
Quoted 5 lines

Looking at commit 86f4b687 I think we also need to add 'sparc' to the polluted_words list (Solaris defines that). I would also be unsurprised to find that some PPC platforms define 'ppc'. (Tricore is probably new enough to have escaped this namespace pollution and we don't support it as a host CPU anyway.)

Do we have anyone that can confirm on these platforms? Obviously, I proved that it's fairly easy to work around, and I don't mind doing the followup patch(es), but only if we have concrete cases where we know it is needed.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw
Quoted 24 lines · Eric Blake
Quoted 17 lines · Peter Maydell
Quoted 10 lines · Eric Blake

Commit 86f4b687 broke compilation on MIPS, which has a preprocessor pollution of '#define mips 1'. Treat it the same way as we do for the pollution with 'unix', so that QMP remains backwards compatible and only the C code needs to use the alternative 'q_mips' spelling.

---

     # namespace pollution:

scripts/qapi.py def c_name(name, protect=True): · line 1488

Quoted 5 lines
scripts/qapi.py +1 -1
-    polluted_words = set(['unix', 'errno'])
+    polluted_words = set(['unix', 'errno', 'mips'])
     name = name.translate(c_name_trans)
     if protect and (name in c89_words | c99_words | c11_words | gcc_words
                     | cpp_words | polluted_words):
Quoted 5 lines

Looking at commit 86f4b687 I think we also need to add 'sparc' to the polluted_words list (Solaris defines that). I would also be unsurprised to find that some PPC platforms define 'ppc'. (Tricore is probably new enough to have escaped this namespace pollution and we don't support it as a host CPU anyway.)

Quoted 4 lines

Do we have anyone that can confirm on these platforms? Obviously, I proved that it's fairly easy to work around, and I don't mind doing the followup patch(es), but only if we have concrete cases where we know it is needed.

I just started up the elderly debian sparc VM image I have lying around and installed the compiler, which is enough to confirm that it does "#define sparc 1".

We know PPC Linux doesn't define 'ppc' because the ppc64be build I do as part of pull request processing worked OK.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728710#25
suggests it uses "powerpc" and "PPC" so we're OK there.

thanks
-- PMM