From: Igor Mammedov <imammedo@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Corey Minyard" <minyard@acm.org>, "Amit Shah" <amit@kernel.org>,
qemu-ppc@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
qemu-devel@nongnu.org, dgilbert@redhat.com, qemu-arm@nongnu.org,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Anthony Perard" <anthony.perard@citrix.com>,
xen-devel@lists.xenproject.org,
"Richard Henderson" <rth@twiddle.net>,
"Andreas Färber" <afaerber@suse.de>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
Date: Wed, 21 Nov 2018 10:10:04 +0100 [thread overview]
Message-ID: <20181121101004.6405408a@redhat.com> (raw)
In-Reply-To: <d84bafe2-184b-bc62-9cde-0d1421cb484d@redhat.com>
On Tue, 20 Nov 2018 19:54:23 +0100
Laszlo Ersek <lersek@redhat.com> wrote:
> On 11/20/18 17:33, Igor Mammedov wrote:
> > On Wed, 7 Nov 2018 16:36:40 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >
> >> Interfaces don't have instance, let's make the interface type really
> >> abstract to avoid confusion.
> >>
> >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> ---
> >> include/hw/acpi/acpi_dev_interface.h | 6 +-----
> >> include/hw/arm/linux-boot-if.h | 5 +----
> >> include/hw/fw-path-provider.h | 4 +---
> >> include/hw/hotplug.h | 6 +-----
> >> include/hw/intc/intc.h | 4 +---
> >> include/hw/ipmi/ipmi.h | 4 +---
> >> include/hw/isa/isa.h | 4 ----
> >> include/hw/mem/memory-device.h | 4 +---
> >> include/hw/nmi.h | 4 +---
> >> include/hw/stream.h | 4 +---
> >> include/hw/timer/m48t59.h | 4 +---
> >> include/qom/object_interfaces.h | 6 +-----
> >> include/sysemu/tpm.h | 4 +---
> >> target/arm/idau.h | 4 +---
> >> tests/check-qom-interface.c | 4 +---
> >> 15 files changed, 14 insertions(+), 53 deletions(-)
> >>
> >> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> >> index dabf4c4fc9..43ff119179 100644
> >> --- a/include/hw/acpi/acpi_dev_interface.h
> >> +++ b/include/hw/acpi/acpi_dev_interface.h
> >> @@ -25,11 +25,7 @@ typedef enum {
> >> INTERFACE_CHECK(AcpiDeviceIf, (obj), \
> >> TYPE_ACPI_DEVICE_IF)
> >>
> >> -
> >> -typedef struct AcpiDeviceIf {
> >> - /* <private> */
> >> - Object Parent;
> >> -} AcpiDeviceIf;
> >> +typedef struct AcpiDeviceIf AcpiDeviceIf;
> >>
> >> void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
> >>
> >> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> >> index aba4479a14..7bbdfd1cc6 100644
> >> --- a/include/hw/arm/linux-boot-if.h
> >> +++ b/include/hw/arm/linux-boot-if.h
> >> @@ -16,10 +16,7 @@
> >> #define ARM_LINUX_BOOT_IF(obj) \
> >> INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
> >>
> >> -typedef struct ARMLinuxBootIf {
> >> - /*< private >*/
> >> - Object parent_obj;
> >> -} ARMLinuxBootIf;
> >> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
> > I like how it makes interface truly opaque and removes the need for
> > structure declaration but:
> >
> > 1: I'm not sure if it's acceptable thing to do from language point of view
>
> Yeah, it's fine. If you have just
>
> struct ARMLinuxBootIf;
>
> (and, optionally, a typedef to it,) then this type is called an
> "incomplete type" (for translation units that don't see the actual type
> definition). You can't apply the "sizeof" operator to it, you can't put
> it in other structs and arrays etc. I'm too lazy to look up the exact
> details in the C standard now. :) But, importantly,
> "pointer-to-ARMLinuxBootIf" is a complete type, and you can do all the
> usual things with that. (Define variables of that pointer type, embed
> them in other structures, use it as an array element type, pass them to
> functions, and so on.)
Thanks Laszlo, that's the answer I was looking for.
> Thanks
> Laszlo
>
> > 2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h
> >
> > [...]
> >
>
>
next prev parent reply other threads:[~2018-11-21 9:10 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 12:36 [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
2018-11-20 15:33 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract Marc-André Lureau
2018-11-20 16:33 ` Igor Mammedov
2018-11-20 17:42 ` Eduardo Habkost
2018-11-20 18:54 ` Laszlo Ersek
2018-11-21 9:10 ` Igor Mammedov [this message]
2018-11-23 14:03 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-11-20 16:39 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 04/14] accel: register global_props like machine globals Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-11-11 23:46 ` Philippe Mathieu-Daudé
2018-11-20 16:40 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props Marc-André Lureau
2018-11-23 14:02 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided Marc-André Lureau
2018-11-23 14:20 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray Marc-André Lureau
2018-11-23 14:26 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props() Marc-André Lureau
2018-11-26 13:20 ` Igor Mammedov
2018-11-26 20:02 ` Marc-André Lureau
2018-11-27 14:12 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init Marc-André Lureau
2018-11-26 13:46 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 12/14] machine: add compat-props interface Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2 Marc-André Lureau
2018-11-07 15:49 ` Marc-André Lureau
2018-11-07 19:01 ` Eduardo Habkost
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1 Marc-André Lureau
2018-11-26 13:55 ` [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181121101004.6405408a@redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=amit@kernel.org \
--cc=anthony.perard@citrix.com \
--cc=atar4qemu@gmail.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=hpoussin@reactos.org \
--cc=lersek@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=minyard@acm.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
--cc=sstabellini@kernel.org \
--cc=stefanb@linux.ibm.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).