[PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"

Paolo Bonzini posted 2 patches 3 years ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210413113741.214867-1-pbonzini@redhat.com
disas/nanomips.cpp      |  2 +-
include/qemu/compiler.h |  6 ++++++
include/qemu/osdep.h    | 13 +++++++++++--
3 files changed, 18 insertions(+), 3 deletions(-)
[PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"
Posted by Paolo Bonzini 3 years ago
qemu/osdep.h is quite special in that, despite being part of QEMU sources,
it is included by C++ source files as well.

disas/nanomips.cpp is doing so within an 'extern "C"' block, which breaks
with latest glib due to the inclusion of templates in glib.h.

These patches implement Daniel Berrangé's idea of pushing the 'extern "C"'
block within glib.h and including system headers (including glib.h,
and in fact QEMU's own glib-compat.h too) *outside* the block.

(CI has not finished running yet, but it seems encouraging).

Paolo

Paolo Bonzini (2):
  osdep: include glib-compat.h before other QEMU headers
  osdep: protect qemu/osdep.h with extern "C"

 disas/nanomips.cpp      |  2 +-
 include/qemu/compiler.h |  6 ++++++
 include/qemu/osdep.h    | 13 +++++++++++--
 3 files changed, 18 insertions(+), 3 deletions(-)

-- 
2.30.1


Re: [PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"
Posted by no-reply@patchew.org 3 years ago
Patchew URL: https://patchew.org/QEMU/20210413113741.214867-1-pbonzini@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210413113741.214867-1-pbonzini@redhat.com
Subject: [PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/20210408195534.647895-1-antonkuchin@yandex-team.ru -> patchew/20210408195534.647895-1-antonkuchin@yandex-team.ru
 * [new tag]         patchew/20210413113741.214867-1-pbonzini@redhat.com -> patchew/20210413113741.214867-1-pbonzini@redhat.com
Switched to a new branch 'test'
992fa52 osdep: protect qemu/osdep.h with extern "C"
bc2310f osdep: include glib-compat.h before other QEMU headers

=== OUTPUT BEGIN ===
1/2 Checking commit bc2310f731a5 (osdep: include glib-compat.h before other QEMU headers)
2/2 Checking commit 992fa52da413 (osdep: protect qemu/osdep.h with extern "C")
WARNING: architecture specific defines should be avoided
#51: FILE: include/qemu/compiler.h:14:
+#ifdef __cplusplus

ERROR: storage class should be at the beginning of the declaration
#52: FILE: include/qemu/compiler.h:15:
+#define QEMU_EXTERN_C extern "C"

ERROR: storage class should be at the beginning of the declaration
#54: FILE: include/qemu/compiler.h:17:
+#define QEMU_EXTERN_C extern

WARNING: architecture specific defines should be avoided
#77: FILE: include/qemu/osdep.h:116:
+#ifdef __cplusplus

WARNING: architecture specific defines should be avoided
#88: FILE: include/qemu/osdep.h:730:
+#ifdef __cplusplus

total: 2 errors, 3 warnings, 47 lines checked

Patch 2/2 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210413113741.214867-1-pbonzini@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"
Posted by Philippe Mathieu-Daudé 3 years ago
Cc'ing MediaTek reviewers.

On 4/13/21 1:37 PM, Paolo Bonzini wrote:
> qemu/osdep.h is quite special in that, despite being part of QEMU sources,
> it is included by C++ source files as well.
> 
> disas/nanomips.cpp is doing so within an 'extern "C"' block, which breaks
> with latest glib due to the inclusion of templates in glib.h.
> 
> These patches implement Daniel Berrangé's idea of pushing the 'extern "C"'
> block within glib.h and including system headers (including glib.h,
> and in fact QEMU's own glib-compat.h too) *outside* the block.
> 
> (CI has not finished running yet, but it seems encouraging).
> 
> Paolo
> 
> Paolo Bonzini (2):
>   osdep: include glib-compat.h before other QEMU headers
>   osdep: protect qemu/osdep.h with extern "C"
> 
>  disas/nanomips.cpp      |  2 +-
>  include/qemu/compiler.h |  6 ++++++
>  include/qemu/osdep.h    | 13 +++++++++++--
>  3 files changed, 18 insertions(+), 3 deletions(-)
> 


Re: [PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"
Posted by Aleksandar Rikalo 3 years ago
Hi Paolo,

Can you specify how to reproduce the issue ? We need more details about environment.

In my case, everything seems to work fine for the newest version of glib (2.68).

Thank you,
Aleksandar

> qemu/osdep.h is quite special in that, despite being part of QEMU sources,
> it is included by C++ source files as well.
>
> disas/nanomips.cpp is doing so within an 'extern "C"' block, which breaks
> with latest glib due to the inclusion of templates in glib.h.
>
> These patches implement Daniel Berrangé's idea of pushing the 'extern "C"'
> block within glib.h and including system headers (including glib.h,
> and in fact QEMU's own glib-compat.h too) *outside* the block.
>
> (CI has not finished running yet, but it seems encouraging).
>
> Paolo
>
> Paolo Bonzini (2):
>   osdep: include glib-compat.h before other QEMU headers
>   osdep: protect qemu/osdep.h with extern "C"
>
>  disas/nanomips.cpp      |  2 +-
>  include/qemu/compiler.h |  6 ++++++
>  include/qemu/osdep.h    | 13 +++++++++++--
>  3 files changed, 18 insertions(+), 3 deletions(-)
>
> --
> 2.30.1
________________________________
From: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> on behalf of Philippe Mathieu-Daudé <f4bug@amsat.org>
Sent: Tuesday, April 13, 2021 5:58 PM
To: Paolo Bonzini <pbonzini@redhat.com>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>
Cc: peter.maydell@linaro.org <peter.maydell@linaro.org>; berrange@redhat.com <berrange@redhat.com>; Aleksandar Rikalo <Aleksandar.Rikalo@syrmia.com>; Vince.DelVecchio@mediatek.com <Vince.DelVecchio@mediatek.com>; Petar Jovanovic <petar.jovanovic@syrmia.com>; Filip Vidojevic <Filip.Vidojevic@Syrmia.com>
Subject: Re: [PATCH 0/2] osdep: allow including qemu/osdep.h outside extern "C"

Cc'ing MediaTek reviewers.

On 4/13/21 1:37 PM, Paolo Bonzini wrote:
> qemu/osdep.h is quite special in that, despite being part of QEMU sources,
> it is included by C++ source files as well.
>
> disas/nanomips.cpp is doing so within an 'extern "C"' block, which breaks
> with latest glib due to the inclusion of templates in glib.h.
>
> These patches implement Daniel Berrangé's idea of pushing the 'extern "C"'
> block within glib.h and including system headers (including glib.h,
> and in fact QEMU's own glib-compat.h too) *outside* the block.
>
> (CI has not finished running yet, but it seems encouraging).
>
> Paolo
>
> Paolo Bonzini (2):
>   osdep: include glib-compat.h before other QEMU headers
>   osdep: protect qemu/osdep.h with extern "C"
>
>  disas/nanomips.cpp      |  2 +-
>  include/qemu/compiler.h |  6 ++++++
>  include/qemu/osdep.h    | 13 +++++++++++--
>  3 files changed, 18 insertions(+), 3 deletions(-)
>