qom: Rename Object::class into Object::klass
PATCH 1/2 qom: Rename Object::class into Object::klass
From: Roman Kiryanov <[email protected]>
'class' is a C++ keyword and it prevents from
using the QEMU headers with a C++ compiler.
Google-Bug-Id: 331190993
--- hw/core/qdev-properties-system.c | 2 +- include/exec/memory.h | 2 +- include/qom/object.h | 2 +- qom/object.c | 90 ++++++++++++++++---------------- 4 files changed, 48 insertions(+), 48 deletions(-)
hw/core/qdev-properties-system.c +1 -1
@@ -431,7 +431,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name, }if (peers[i]->info->check_peer_type) { -if (!peers[i]->info->check_peer_type (peers[i], obj->class, errp)) { +if (!peers[i]->info->check_peer_type (peers[i], obj->klass, errp)) { goto out; } }
include/exec/memory.h +1 -1
@@ -1808,7 +1808,7 @@ static inline IOMMUMemoryRegion *memory_region_get_iommu(MemoryRegion *mr)static inline IOMMUMemoryRegionClass *memory_region_get_iommu_class_nocheck (IOMMUMemoryRegion *iommu_mr) { -return (IOMMUMemoryRegionClass *) (((Object *)iommu_mr)->class); +return (IOMMUMemoryRegionClass *) (((Object *)iommu_mr)->klass); }#define memory_region_is_iommu (mr) (memory_region_get_iommu(mr) != NULL)
include/qom/object.h +1 -1
@@ -153,7 +153,7 @@ struct ObjectClassstruct Object {/* private: */ -ObjectClass *class; +ObjectClass *klass;ObjectFree *free;GHashTable *properties;uint32_t ref;
qom/object.c +45 -45
254 lines not on this page · raw message
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
PATCH 2/2 include/qom: Rename typename into type_name
From: Roman Kiryanov <[email protected]>
typename is a C++ keyword and it prevents from
using the QEMU headers with a C++ compiler.
Google-Bug-Id: 331190993
--- hw/core/bus.c | 8 +-- include/hw/qdev-core.h | 4 +- include/qom/object.h | 78 +++++++++++++-------------- qom/object.c | 120 ++++++++++++++++++++--------------------- 4 files changed, 105 insertions(+), 105 deletions(-)
hw/core/bus.c +4 -4
@@ -152,18 +152,18 @@ static void bus_unparent(Object *obj) bus->parent =NULL ; } -void qbus_init (void *bus,size_t size,const char *typename, +void qbus_init (void *bus,size_t size,const char *type_name,DeviceState *parent,const char *name) { -object_initialize (bus, size, typename); +object_initialize (bus, size, type_name);qbus_init_internal (bus, parent, name); } -BusState *qbus_new (const char *typename,DeviceState *parent,const char *name) +BusState *qbus_new (const char *type_name,DeviceState *parent,const char *name) {BusState *bus; - bus =BUS (object_new (typename)); + bus =BUS (object_new (type_name));qbus_init_internal (bus, parent, name);return bus;
include/hw/qdev-core.h +2 -2
@@ -867,9 +867,9 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id);typedef int (qbus_walkerfn )(BusState *bus,void *opaque);typedef int (qdev_walkerfn )(DeviceState *dev,void *opaque); -void qbus_init (void *bus,size_t size,const char *typename, +void qbus_init (void *bus,size_t size,const char *type_name,DeviceState *parent,const char *name); -BusState *qbus_new (const char *typename,DeviceState *parent,const char *name); +BusState *qbus_new (const char *type_name,DeviceState *parent,const char *name);bool qbus_realize (BusState *bus,Error **errp);void qbus_unrealize (BusState *bus);
include/qom/object.h +39 -39
242 lines not on this page · raw message
qom/object.c +60 -60
389 lines not on this page · raw message
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
Hi Felix,
Quoted 6 lines · Felix Wu
From: Roman Kiryanov <[email protected]>
'class' is a C++ keyword and it prevents from
using the QEMU headers with a C++ compiler.Google-Bug-Id: 331190993
I asked Roman twice about this tag meaning:
https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/[email protected]/
Since you are taking his work, do you mind clarifying?
Please include a cover letter for your series:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#include-a-meaningful-cover-letter
Also for headers refactors, enabling scripts/git.orderfile helps reviewers.
Since you are posting different C++ enablement cleanups, I suggest you add a section in our docs/devel/style.rst requesting to keep headers C++ compatible, by not using C++ reserved keywords, etc...
In particular because the mainstream project is not build-testing for C++, thus we will likely merge patches breaking C++ and make your life harder. That said, a C++ header smoke-build job in our CI could help.
Quoted 16 lines
Change-Id I9ab7d2d77edef654a9c7b7cb9cd01795a6ed65a2Signed-off-by Felix Wu <[email protected]>Signed-off-by Roman Kiryanov <[email protected]>--- hw/core/qdev-properties-system.c | 2 +- include/exec/memory.h | 2 +- include/qom/object.h | 2 +- qom/object.c | 90 ++++++++++++++++---------------- 4 files changed, 48 insertions(+), 48 deletions(-)include/qom/object.h +0
-0
include/qom/object.h struct ObjectClass · line 159
Quoted 8 lines
include/qom/object.h +1
-1@@ -153,7 +153,7 @@ struct ObjectClassstruct Object {/* private: */ -ObjectClass *class; +ObjectClass *klass;ObjectFree *free;GHashTable *properties;uint32_t ref;
I suppose the OBJECT_CLASS / OBJECT_CLASS_CHECK / OBJECT_GET_CLASS macros aren't compiled so "class" isn't a problem there.
Since it isn't worst than our INTERFACE_CLASS() use:
Regards,
Phil.
Quoted 9 lines · Philippe Mathieu-Daudé
Since you are posting different C++ enablement cleanups, I suggest you add a section in our
docs/devel/style.rstrequesting to keep headers C++ compatible, by not using C++ reserved keywords, etc...In particular because the mainstream project is not build-testing for C++, thus we will likely merge patches breaking C++ and make your life harder. That said, a C++ header smoke-build job in our CI could help.
Unless there's some easy mechanism for contributors to check that they haven't broken whatever our C++ requirement is, I don't think we should define it in the style guide.
More generally, we specifically removed the handling we had for being able to include our headers from C++ source files. (cf the stuff we added in commit 875df03b221 for extern "C" blocks and then removed again later). If we're not bringing that back (and I don't think we should) then we're not actually trying to have our headers be C++ compatible, so what are we aiming for?
thanks
-- PMM
Quoted 15 lines · Peter Maydell
Quoted 9 lines · Philippe Mathieu-Daudé
Since you are posting different C++ enablement cleanups, I suggest you add a section in our
docs/devel/style.rstrequesting to keep headers C++ compatible, by not using C++ reserved keywords, etc...In particular because the mainstream project is not build-testing for C++, thus we will likely merge patches breaking C++ and make your life harder. That said, a C++ header smoke-build job in our CI could help.
Unless there's some easy mechanism for contributors to check that they haven't broken whatever our C++ requirement is, I don't think we should define it in the style guide.
Quoted 7 lines
More generally, we specifically removed the handling we had for being able to include our headers from C++ source files. (cf the stuff we added in commit
875df03b221for extern "C" blocks and then removed again later). If we're not bringing that back (and I don't think we should) then we're not actually trying to have our headers be C++ compatible, so what are we aiming for?
I really dislike the drip-feeding of patches fixing C++ related problems. As maintainers we've no idea what the end state is, is this the last patch, or are there another 100 of these patches to trickle out one at a time. Ultimately from the QEMU maintainer POV anything related to C++ compatibility is a distraction, given the general consensus has turned to Rust as the future for QEMU, not C++.
If we're going to take any C++ compat cleanups as a courtesy to ease burden of a downstream fork, then I'd like to see a complete series in one go, so we can sensibly evaluate whether the end state is something desirable from QEMU's POV.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 7 lines · Felix Wu
From: Roman Kiryanov <[email protected]>
'class' is a C++ keyword and it prevents from
using the QEMU headers with a C++ compiler.Google-Bug-Id: 331190993
Change-Id: I9ab7d2d77edef654a9c7b7cb9cd01795a6ed65a2
Please remove both of these lines when posting patches. They are irrelevant to QEMU's git commit history.
Quoted 8 lines
Signed-off-by Felix Wu <[email protected]>Signed-off-by Roman Kiryanov <[email protected]>--- hw/core/qdev-properties-system.c | 2 +- include/exec/memory.h | 2 +- include/qom/object.h | 2 +- qom/object.c | 90 ++++++++++++++++---------------- 4 files changed, 48 insertions(+), 48 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|