qapi: Fix compilation failure on MIPS
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
@@ -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
@@ -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
@@ -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
Quoted 7 lines · Eric Blake
Commit
86f4b687broke 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.CC James Hogan <[email protected]>Signed-off-by Eric Blake <[email protected]>
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@@ -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@@ -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@@ -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
Markus Armbruster
AppliedQuoted 7 lines · Eric Blake
Commit
86f4b687broke 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.CC James Hogan <[email protected]>Signed-off-by Eric Blake <[email protected]>
Applied to qapi-next, thanks!
Quoted 18 lines · Eric Blake
Commit
86f4b687broke 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.CC James Hogan <[email protected]>Signed-off-by Eric Blake <[email protected]>--- scripts/qapi.py | 2 +- cpus.c | 4 ++-- hmp.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)scripts/qapi.py +0
-0
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
Quoted 17 lines · Peter Maydell
Quoted 10 lines · Eric Blake
Commit
86f4b687broke 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.CC James Hogan <[email protected]>Signed-off-by Eric Blake <[email protected]>---
# 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
86f4b687I think we also need to add 'sparc' to thepolluted_wordslist (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
Quoted 24 lines · Eric Blake
Quoted 17 lines · Peter Maydell
Quoted 10 lines · Eric Blake
Commit
86f4b687broke 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.CC James Hogan <[email protected]>Signed-off-by Eric Blake <[email protected]>---
# 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
86f4b687I think we also need to add 'sparc' to thepolluted_wordslist (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