All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
@ 2017-06-22 16:06 Greg Kurz
  2017-06-22 16:14 ` Peter Maydell
  0 siblings, 1 reply; 16+ messages in thread
From: Greg Kurz @ 2017-06-22 16:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Dr. David Alan Gilbert

Function types cannot reside in the same sorted list as opaque types since
they may depend on a type which would be defined later.

Of course, the same problem could arise if a function type depends on
another function type with greater alphabetical order. Hopefully we
don't have that at this time.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 include/qemu/typedefs.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index f745d5faf7fd..cd3e369ae01a 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -1,10 +1,9 @@
 #ifndef QEMU_TYPEDEFS_H
 #define QEMU_TYPEDEFS_H
 
-/* A load of opaque types so that device init declarations don't have to
-   pull in all the real definitions.  */
-
-/* Please keep this list in alphabetical order */
+/* First list is for opaque types only, second one for function types.
+ * Please keep both lists in alphabetical order.
+ */
 typedef struct AdapterInfo AdapterInfo;
 typedef struct AddressSpace AddressSpace;
 typedef struct AioContext AioContext;
@@ -96,7 +95,8 @@ typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct Visitor Visitor;
 typedef struct node_info NodeInfo;
+
+typedef int  LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
-typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
 
 #endif /* QEMU_TYPEDEFS_H */

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 16:06 [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h Greg Kurz
@ 2017-06-22 16:14 ` Peter Maydell
  2017-06-22 16:42   ` Greg Kurz
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Maydell @ 2017-06-22 16:14 UTC (permalink / raw)
  To: Greg Kurz; +Cc: QEMU Developers, QEMU Trivial, Dr. David Alan Gilbert

On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:
> Function types cannot reside in the same sorted list as opaque types since
> they may depend on a type which would be defined later.
>
> Of course, the same problem could arise if a function type depends on
> another function type with greater alphabetical order. Hopefully we
> don't have that at this time.

The other approach would be to put function types somewhere
else and leave typedefs.h for the simple 'opaque types
for structures' that it was started as.

For instance we have include/qemu/fprintf-fn.h as a precedent.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 16:14 ` Peter Maydell
@ 2017-06-22 16:42   ` Greg Kurz
  2017-06-22 17:03     ` Juan Quintela
  0 siblings, 1 reply; 16+ messages in thread
From: Greg Kurz @ 2017-06-22 16:42 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Developers, QEMU Trivial, Dr. David Alan Gilbert, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On Thu, 22 Jun 2017 17:14:08 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:
> > Function types cannot reside in the same sorted list as opaque types since
> > they may depend on a type which would be defined later.
> >
> > Of course, the same problem could arise if a function type depends on
> > another function type with greater alphabetical order. Hopefully we
> > don't have that at this time.  
> 
> The other approach would be to put function types somewhere
> else and leave typedefs.h for the simple 'opaque types
> for structures' that it was started as.
> 
> For instance we have include/qemu/fprintf-fn.h as a precedent.
> 

Indeed, and I'm not quite sure why Juan decided to put these types into
typedefs.h instead of a dedicated header file in include/migration... is
it only because it was the quickest fix ?

> thanks
> -- PMM


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 16:42   ` Greg Kurz
@ 2017-06-22 17:03     ` Juan Quintela
  2017-06-22 17:22       ` Peter Maydell
  0 siblings, 1 reply; 16+ messages in thread
From: Juan Quintela @ 2017-06-22 17:03 UTC (permalink / raw)
  To: Greg Kurz
  Cc: Peter Maydell, QEMU Developers, QEMU Trivial, Dr. David Alan Gilbert

Greg Kurz <groug@kaod.org> wrote:
> On Thu, 22 Jun 2017 17:14:08 +0100
> Peter Maydell <peter.maydell@linaro.org> wrote:
>
>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:
>> > Function types cannot reside in the same sorted list as opaque types since
>> > they may depend on a type which would be defined later.
>> >
>> > Of course, the same problem could arise if a function type depends on
>> > another function type with greater alphabetical order. Hopefully we
>> > don't have that at this time.  
>> 
>> The other approach would be to put function types somewhere
>> else and leave typedefs.h for the simple 'opaque types
>> for structures' that it was started as.
>> 
>> For instance we have include/qemu/fprintf-fn.h as a precedent.
>> 
>
> Indeed, and I'm not quite sure why Juan decided to put these types into
> typedefs.h instead of a dedicated header file in include/migration... is
> it only because it was the quickest fix ?

All other typedefs were defined there.  I can create a different include
file, but I think that is "overengineering", no?  They are typedefs,
just not of structs.  But I agree that they are the only ones.

Later, Juan.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 17:03     ` Juan Quintela
@ 2017-06-22 17:22       ` Peter Maydell
  2017-06-22 17:25         ` Dr. David Alan Gilbert
  2017-06-23  7:04         ` Markus Armbruster
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Maydell @ 2017-06-22 17:22 UTC (permalink / raw)
  To: Juan Quintela
  Cc: Greg Kurz, QEMU Developers, QEMU Trivial, Dr. David Alan Gilbert

On 22 June 2017 at 18:03, Juan Quintela <quintela@redhat.com> wrote:
> Greg Kurz <groug@kaod.org> wrote:
>> On Thu, 22 Jun 2017 17:14:08 +0100
>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:
>>> > Function types cannot reside in the same sorted list as opaque types since
>>> > they may depend on a type which would be defined later.
>>> >
>>> > Of course, the same problem could arise if a function type depends on
>>> > another function type with greater alphabetical order. Hopefully we
>>> > don't have that at this time.
>>>
>>> The other approach would be to put function types somewhere
>>> else and leave typedefs.h for the simple 'opaque types
>>> for structures' that it was started as.
>>>
>>> For instance we have include/qemu/fprintf-fn.h as a precedent.
>>>
>>
>> Indeed, and I'm not quite sure why Juan decided to put these types into
>> typedefs.h instead of a dedicated header file in include/migration... is
>> it only because it was the quickest fix ?
>
> All other typedefs were defined there.  I can create a different include
> file, but I think that is "overengineering", no?  They are typedefs,
> just not of structs.  But I agree that they are the only ones.

Well, the comment in the file says "opaque types so that device init
declarations don't have to pull in all the real definitions", whereas
the ones you've added aren't opaque types, they are the real
definitions. They're also only used by a very small subset of .c
files, whereas typedefs.h goes everywhere.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 17:22       ` Peter Maydell
@ 2017-06-22 17:25         ` Dr. David Alan Gilbert
  2017-06-22 17:46           ` Greg Kurz
  2017-06-23  7:04         ` Markus Armbruster
  1 sibling, 1 reply; 16+ messages in thread
From: Dr. David Alan Gilbert @ 2017-06-22 17:25 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Juan Quintela, Greg Kurz, QEMU Developers, QEMU Trivial

* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 22 June 2017 at 18:03, Juan Quintela <quintela@redhat.com> wrote:
> > Greg Kurz <groug@kaod.org> wrote:
> >> On Thu, 22 Jun 2017 17:14:08 +0100
> >> Peter Maydell <peter.maydell@linaro.org> wrote:
> >>
> >>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:
> >>> > Function types cannot reside in the same sorted list as opaque types since
> >>> > they may depend on a type which would be defined later.
> >>> >
> >>> > Of course, the same problem could arise if a function type depends on
> >>> > another function type with greater alphabetical order. Hopefully we
> >>> > don't have that at this time.
> >>>
> >>> The other approach would be to put function types somewhere
> >>> else and leave typedefs.h for the simple 'opaque types
> >>> for structures' that it was started as.
> >>>
> >>> For instance we have include/qemu/fprintf-fn.h as a precedent.
> >>>
> >>
> >> Indeed, and I'm not quite sure why Juan decided to put these types into
> >> typedefs.h instead of a dedicated header file in include/migration... is
> >> it only because it was the quickest fix ?
> >
> > All other typedefs were defined there.  I can create a different include
> > file, but I think that is "overengineering", no?  They are typedefs,
> > just not of structs.  But I agree that they are the only ones.
> 
> Well, the comment in the file says "opaque types so that device init
> declarations don't have to pull in all the real definitions", whereas
> the ones you've added aren't opaque types, they are the real
> definitions. They're also only used by a very small subset of .c
> files, whereas typedefs.h goes everywhere.

mv fprintf-fn.f   fn-typedefs.h

move those two defs into that?

Dave

> thanks
> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 17:25         ` Dr. David Alan Gilbert
@ 2017-06-22 17:46           ` Greg Kurz
  2017-06-22 17:50             ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 16+ messages in thread
From: Greg Kurz @ 2017-06-22 17:46 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Peter Maydell, QEMU Developers, QEMU Trivial, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

On Thu, 22 Jun 2017 18:25:55 +0100
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:

> * Peter Maydell (peter.maydell@linaro.org) wrote:
> > On 22 June 2017 at 18:03, Juan Quintela <quintela@redhat.com> wrote:  
> > > Greg Kurz <groug@kaod.org> wrote:  
> > >> On Thu, 22 Jun 2017 17:14:08 +0100
> > >> Peter Maydell <peter.maydell@linaro.org> wrote:
> > >>  
> > >>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:  
> > >>> > Function types cannot reside in the same sorted list as opaque types since
> > >>> > they may depend on a type which would be defined later.
> > >>> >
> > >>> > Of course, the same problem could arise if a function type depends on
> > >>> > another function type with greater alphabetical order. Hopefully we
> > >>> > don't have that at this time.  
> > >>>
> > >>> The other approach would be to put function types somewhere
> > >>> else and leave typedefs.h for the simple 'opaque types
> > >>> for structures' that it was started as.
> > >>>
> > >>> For instance we have include/qemu/fprintf-fn.h as a precedent.
> > >>>  
> > >>
> > >> Indeed, and I'm not quite sure why Juan decided to put these types into
> > >> typedefs.h instead of a dedicated header file in include/migration... is
> > >> it only because it was the quickest fix ?  
> > >
> > > All other typedefs were defined there.  I can create a different include
> > > file, but I think that is "overengineering", no?  They are typedefs,
> > > just not of structs.  But I agree that they are the only ones.  
> > 
> > Well, the comment in the file says "opaque types so that device init
> > declarations don't have to pull in all the real definitions", whereas
> > the ones you've added aren't opaque types, they are the real
> > definitions. They're also only used by a very small subset of .c
> > files, whereas typedefs.h goes everywhere.  
> 
> mv fprintf-fn.f   fn-typedefs.h
> 
> move those two defs into that?
> 

Wouldn't it be more appropriate to put them in a dedicated
include/migration/handler-fn.h header included by both
vmstate.h and register.h ?

> Dave
> 
> > thanks
> > -- PMM  
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 17:46           ` Greg Kurz
@ 2017-06-22 17:50             ` Dr. David Alan Gilbert
  2017-06-22 18:08               ` Thomas Huth
  0 siblings, 1 reply; 16+ messages in thread
From: Dr. David Alan Gilbert @ 2017-06-22 17:50 UTC (permalink / raw)
  To: Greg Kurz; +Cc: Peter Maydell, QEMU Developers, QEMU Trivial, Juan Quintela

* Greg Kurz (groug@kaod.org) wrote:
> On Thu, 22 Jun 2017 18:25:55 +0100
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> 
> > * Peter Maydell (peter.maydell@linaro.org) wrote:
> > > On 22 June 2017 at 18:03, Juan Quintela <quintela@redhat.com> wrote:  
> > > > Greg Kurz <groug@kaod.org> wrote:  
> > > >> On Thu, 22 Jun 2017 17:14:08 +0100
> > > >> Peter Maydell <peter.maydell@linaro.org> wrote:
> > > >>  
> > > >>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:  
> > > >>> > Function types cannot reside in the same sorted list as opaque types since
> > > >>> > they may depend on a type which would be defined later.
> > > >>> >
> > > >>> > Of course, the same problem could arise if a function type depends on
> > > >>> > another function type with greater alphabetical order. Hopefully we
> > > >>> > don't have that at this time.  
> > > >>>
> > > >>> The other approach would be to put function types somewhere
> > > >>> else and leave typedefs.h for the simple 'opaque types
> > > >>> for structures' that it was started as.
> > > >>>
> > > >>> For instance we have include/qemu/fprintf-fn.h as a precedent.
> > > >>>  
> > > >>
> > > >> Indeed, and I'm not quite sure why Juan decided to put these types into
> > > >> typedefs.h instead of a dedicated header file in include/migration... is
> > > >> it only because it was the quickest fix ?  
> > > >
> > > > All other typedefs were defined there.  I can create a different include
> > > > file, but I think that is "overengineering", no?  They are typedefs,
> > > > just not of structs.  But I agree that they are the only ones.  
> > > 
> > > Well, the comment in the file says "opaque types so that device init
> > > declarations don't have to pull in all the real definitions", whereas
> > > the ones you've added aren't opaque types, they are the real
> > > definitions. They're also only used by a very small subset of .c
> > > files, whereas typedefs.h goes everywhere.  
> > 
> > mv fprintf-fn.f   fn-typedefs.h
> > 
> > move those two defs into that?
> > 
> 
> Wouldn't it be more appropriate to put them in a dedicated
> include/migration/handler-fn.h header included by both
> vmstate.h and register.h ?

Could do; I'm just not finding tiny header files with one or
two entries each that useful.

Dave

> > Dave
> > 
> > > thanks
> > > -- PMM  
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> > 
> 


--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 17:50             ` Dr. David Alan Gilbert
@ 2017-06-22 18:08               ` Thomas Huth
  2017-06-22 18:11                 ` Peter Maydell
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Huth @ 2017-06-22 18:08 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Greg Kurz
  Cc: QEMU Trivial, Peter Maydell, QEMU Developers, Juan Quintela

On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:
> * Greg Kurz (groug@kaod.org) wrote:
>> On Thu, 22 Jun 2017 18:25:55 +0100
>> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
>>
>>> * Peter Maydell (peter.maydell@linaro.org) wrote:
>>>> On 22 June 2017 at 18:03, Juan Quintela <quintela@redhat.com> wrote:  
>>>>> Greg Kurz <groug@kaod.org> wrote:  
>>>>>> On Thu, 22 Jun 2017 17:14:08 +0100
>>>>>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>>>>>  
>>>>>>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:  
>>>>>>>> Function types cannot reside in the same sorted list as opaque types since
>>>>>>>> they may depend on a type which would be defined later.
>>>>>>>>
>>>>>>>> Of course, the same problem could arise if a function type depends on
>>>>>>>> another function type with greater alphabetical order. Hopefully we
>>>>>>>> don't have that at this time.  
>>>>>>>
>>>>>>> The other approach would be to put function types somewhere
>>>>>>> else and leave typedefs.h for the simple 'opaque types
>>>>>>> for structures' that it was started as.
>>>>>>>
>>>>>>> For instance we have include/qemu/fprintf-fn.h as a precedent.
>>>>>>>  
>>>>>>
>>>>>> Indeed, and I'm not quite sure why Juan decided to put these types into
>>>>>> typedefs.h instead of a dedicated header file in include/migration... is
>>>>>> it only because it was the quickest fix ?  
>>>>>
>>>>> All other typedefs were defined there.  I can create a different include
>>>>> file, but I think that is "overengineering", no?  They are typedefs,
>>>>> just not of structs.  But I agree that they are the only ones.  
>>>>
>>>> Well, the comment in the file says "opaque types so that device init
>>>> declarations don't have to pull in all the real definitions", whereas
>>>> the ones you've added aren't opaque types, they are the real
>>>> definitions. They're also only used by a very small subset of .c
>>>> files, whereas typedefs.h goes everywhere.  
>>>
>>> mv fprintf-fn.f   fn-typedefs.h
>>>
>>> move those two defs into that?
>>>
>>
>> Wouldn't it be more appropriate to put them in a dedicated
>> include/migration/handler-fn.h header included by both
>> vmstate.h and register.h ?
> 
> Could do; I'm just not finding tiny header files with one or
> two entries each that useful.

Do we really need these function typedefs at all? IMHO it's quite ugly
to hide such things in a typedef unless it is really necessary (and in
this case, it does not seem to be really necessary since it is only used
in a few places). So what about simply removing the typedefs in this case?

 Thomas

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 18:08               ` Thomas Huth
@ 2017-06-22 18:11                 ` Peter Maydell
  2017-06-22 18:34                   ` Dr. David Alan Gilbert
  2017-06-23  7:11                   ` Markus Armbruster
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Maydell @ 2017-06-22 18:11 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Dr. David Alan Gilbert, Greg Kurz, QEMU Trivial, QEMU Developers,
	Juan Quintela

On 22 June 2017 at 19:08, Thomas Huth <thuth@redhat.com> wrote:
> On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:
>> Could do; I'm just not finding tiny header files with one or
>> two entries each that useful.

Well, it means that the bulk of code that doesn't care about the
types doesn't get its compilation fractionally slowed by having
to parse the typedef anyway. In general I think we're drifting
towards "have each .c file get fewer things automatically" rather
than otherwise (eg more finely focused files rather than stuffing
everything into qemu-common.h).

> Do we really need these function typedefs at all? IMHO it's quite ugly
> to hide such things in a typedef unless it is really necessary (and in
> this case, it does not seem to be really necessary since it is only used
> in a few places). So what about simply removing the typedefs in this case?

I find function typedefs much more readable than having the
function-types inline in function arguments and the like.

This is all fairly rapidly heading into bikeshed territory
though -- in the final analysis I don't think it matters
much what we do.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 18:11                 ` Peter Maydell
@ 2017-06-22 18:34                   ` Dr. David Alan Gilbert
  2017-06-22 19:23                     ` Greg Kurz
  2017-06-23  7:11                   ` Markus Armbruster
  1 sibling, 1 reply; 16+ messages in thread
From: Dr. David Alan Gilbert @ 2017-06-22 18:34 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Thomas Huth, Greg Kurz, QEMU Trivial, QEMU Developers, Juan Quintela

* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 22 June 2017 at 19:08, Thomas Huth <thuth@redhat.com> wrote:
> > On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:
> >> Could do; I'm just not finding tiny header files with one or
> >> two entries each that useful.
> 
> Well, it means that the bulk of code that doesn't care about the
> types doesn't get its compilation fractionally slowed by having
> to parse the typedef anyway. In general I think we're drifting
> towards "have each .c file get fewer things automatically" rather
> than otherwise (eg more finely focused files rather than stuffing
> everything into qemu-common.h).

At the cost of things getting fractionally slower by including lots
more tiny headers.

I generally agree in the case where there's a useful chunk,
but when it's down to one or two definitions I don't see the point.

> > Do we really need these function typedefs at all? IMHO it's quite ugly
> > to hide such things in a typedef unless it is really necessary (and in
> > this case, it does not seem to be really necessary since it is only used
> > in a few places). So what about simply removing the typedefs in this case?
> 
> I find function typedefs much more readable than having the
> function-types inline in function arguments and the like.
> 
> This is all fairly rapidly heading into bikeshed territory
> though -- in the final analysis I don't think it matters
> much what we do.

Agreed.

Dave

> thanks
> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 18:34                   ` Dr. David Alan Gilbert
@ 2017-06-22 19:23                     ` Greg Kurz
  2017-06-26  9:27                       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 16+ messages in thread
From: Greg Kurz @ 2017-06-22 19:23 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Peter Maydell, Thomas Huth, QEMU Trivial, QEMU Developers, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 2043 bytes --]

On Thu, 22 Jun 2017 19:34:58 +0100
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:

> * Peter Maydell (peter.maydell@linaro.org) wrote:
> > On 22 June 2017 at 19:08, Thomas Huth <thuth@redhat.com> wrote:  
> > > On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:  
> > >> Could do; I'm just not finding tiny header files with one or
> > >> two entries each that useful.  
> > 
> > Well, it means that the bulk of code that doesn't care about the
> > types doesn't get its compilation fractionally slowed by having
> > to parse the typedef anyway. In general I think we're drifting
> > towards "have each .c file get fewer things automatically" rather
> > than otherwise (eg more finely focused files rather than stuffing
> > everything into qemu-common.h).  
> 
> At the cost of things getting fractionally slower by including lots
> more tiny headers.
> 
> I generally agree in the case where there's a useful chunk,
> but when it's down to one or two definitions I don't see the point.
> 
> > > Do we really need these function typedefs at all? IMHO it's quite ugly
> > > to hide such things in a typedef unless it is really necessary (and in
> > > this case, it does not seem to be really necessary since it is only used
> > > in a few places). So what about simply removing the typedefs in this case?  
> > 
> > I find function typedefs much more readable than having the
> > function-types inline in function arguments and the like.
> > 
> > This is all fairly rapidly heading into bikeshed territory
> > though -- in the final analysis I don't think it matters
> > much what we do.  
> 
> Agreed.
> 

Last question for my own comprehension.

I can't think of a case where we would do something like:

   some_vmsd->load_state_old = some_se->ops->load_state;

Does it make sense for VMStateDescription::load_state_old and SaveVMHandlers::load_state
to be of the same type ?

> Dave
> 
> > thanks
> > -- PMM  
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 17:22       ` Peter Maydell
  2017-06-22 17:25         ` Dr. David Alan Gilbert
@ 2017-06-23  7:04         ` Markus Armbruster
  1 sibling, 0 replies; 16+ messages in thread
From: Markus Armbruster @ 2017-06-23  7:04 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Juan Quintela, QEMU Trivial, Greg Kurz, Dr. David Alan Gilbert,
	QEMU Developers

Peter Maydell <peter.maydell@linaro.org> writes:

> On 22 June 2017 at 18:03, Juan Quintela <quintela@redhat.com> wrote:
>> Greg Kurz <groug@kaod.org> wrote:
>>> On Thu, 22 Jun 2017 17:14:08 +0100
>>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>>
>>>> On 22 June 2017 at 17:06, Greg Kurz <groug@kaod.org> wrote:
>>>> > Function types cannot reside in the same sorted list as opaque types since
>>>> > they may depend on a type which would be defined later.
>>>> >
>>>> > Of course, the same problem could arise if a function type depends on
>>>> > another function type with greater alphabetical order. Hopefully we
>>>> > don't have that at this time.
>>>>
>>>> The other approach would be to put function types somewhere
>>>> else and leave typedefs.h for the simple 'opaque types
>>>> for structures' that it was started as.
>>>>
>>>> For instance we have include/qemu/fprintf-fn.h as a precedent.
>>>>
>>>
>>> Indeed, and I'm not quite sure why Juan decided to put these types into
>>> typedefs.h instead of a dedicated header file in include/migration... is
>>> it only because it was the quickest fix ?
>>
>> All other typedefs were defined there.  I can create a different include
>> file, but I think that is "overengineering", no?  They are typedefs,
>> just not of structs.  But I agree that they are the only ones.
>
> Well, the comment in the file says "opaque types so that device init
> declarations don't have to pull in all the real definitions", whereas
> the ones you've added aren't opaque types, they are the real
> definitions.

The comment is out of date.  The header declares many opaque types that
have nothing to do with "device init declarations".  Suggest to simply
delete the comment.  The technique to declare opaque types in one place
and define them elsewhere is common enough not to require justification.

>              They're also only used by a very small subset of .c
> files, whereas typedefs.h goes everywhere.

Yes.  Can we find a suitable migration header for them?

I don't like tiny header files such as qemu/fnprintf-fn.h.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 18:11                 ` Peter Maydell
  2017-06-22 18:34                   ` Dr. David Alan Gilbert
@ 2017-06-23  7:11                   ` Markus Armbruster
  2017-06-28  9:32                     ` Juan Quintela
  1 sibling, 1 reply; 16+ messages in thread
From: Markus Armbruster @ 2017-06-23  7:11 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Thomas Huth, QEMU Trivial, QEMU Developers, Juan Quintela,
	Dr. David Alan Gilbert, Greg Kurz

Peter Maydell <peter.maydell@linaro.org> writes:

> On 22 June 2017 at 19:08, Thomas Huth <thuth@redhat.com> wrote:
>> On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:
>>> Could do; I'm just not finding tiny header files with one or
>>> two entries each that useful.
>
> Well, it means that the bulk of code that doesn't care about the
> types doesn't get its compilation fractionally slowed by having
> to parse the typedef anyway. In general I think we're drifting
> towards "have each .c file get fewer things automatically" rather
> than otherwise (eg more finely focused files rather than stuffing
> everything into qemu-common.h).

Yes.  See also "Our use of #include is undisciplined, and what to do
about it"
Message-ID: <87wpp4m6n1.fsf@blackfin.pond.sub.org>
https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03271.html

I have some unfinished work towards emptying out qemu-common.h.  Need
to find the time to finish it.

[...]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-22 19:23                     ` Greg Kurz
@ 2017-06-26  9:27                       ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 16+ messages in thread
From: Dr. David Alan Gilbert @ 2017-06-26  9:27 UTC (permalink / raw)
  To: Greg Kurz
  Cc: Peter Maydell, Thomas Huth, QEMU Trivial, QEMU Developers, Juan Quintela

* Greg Kurz (groug@kaod.org) wrote:
> On Thu, 22 Jun 2017 19:34:58 +0100
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> 
> > * Peter Maydell (peter.maydell@linaro.org) wrote:
> > > On 22 June 2017 at 19:08, Thomas Huth <thuth@redhat.com> wrote:  
> > > > On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:  
> > > >> Could do; I'm just not finding tiny header files with one or
> > > >> two entries each that useful.  
> > > 
> > > Well, it means that the bulk of code that doesn't care about the
> > > types doesn't get its compilation fractionally slowed by having
> > > to parse the typedef anyway. In general I think we're drifting
> > > towards "have each .c file get fewer things automatically" rather
> > > than otherwise (eg more finely focused files rather than stuffing
> > > everything into qemu-common.h).  
> > 
> > At the cost of things getting fractionally slower by including lots
> > more tiny headers.
> > 
> > I generally agree in the case where there's a useful chunk,
> > but when it's down to one or two definitions I don't see the point.
> > 
> > > > Do we really need these function typedefs at all? IMHO it's quite ugly
> > > > to hide such things in a typedef unless it is really necessary (and in
> > > > this case, it does not seem to be really necessary since it is only used
> > > > in a few places). So what about simply removing the typedefs in this case?  
> > > 
> > > I find function typedefs much more readable than having the
> > > function-types inline in function arguments and the like.
> > > 
> > > This is all fairly rapidly heading into bikeshed territory
> > > though -- in the final analysis I don't think it matters
> > > much what we do.  
> > 
> > Agreed.
> > 
> 
> Last question for my own comprehension.
> 
> I can't think of a case where we would do something like:
> 
>    some_vmsd->load_state_old = some_se->ops->load_state;
> 
> Does it make sense for VMStateDescription::load_state_old and SaveVMHandlers::load_state
> to be of the same type ?

(I think this is what we discussed on irc)
There's only a few _old's and they're the same interface as the
non-_old's,   the only difference is the range of version_id's they're
prepared to take.

Dave

> > Dave
> > 
> > > thanks
> > > -- PMM  
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> 


--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h
  2017-06-23  7:11                   ` Markus Armbruster
@ 2017-06-28  9:32                     ` Juan Quintela
  0 siblings, 0 replies; 16+ messages in thread
From: Juan Quintela @ 2017-06-28  9:32 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Peter Maydell, Thomas Huth, QEMU Trivial, QEMU Developers,
	Dr. David Alan Gilbert, Greg Kurz

Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On 22 June 2017 at 19:08, Thomas Huth <thuth@redhat.com> wrote:
>>> On 22.06.2017 19:50, Dr. David Alan Gilbert wrote:
>>>> Could do; I'm just not finding tiny header files with one or
>>>> two entries each that useful.
>>
>> Well, it means that the bulk of code that doesn't care about the
>> types doesn't get its compilation fractionally slowed by having
>> to parse the typedef anyway. In general I think we're drifting
>> towards "have each .c file get fewer things automatically" rather
>> than otherwise (eg more finely focused files rather than stuffing
>> everything into qemu-common.h).
>
> Yes.  See also "Our use of #include is undisciplined, and what to do
> about it"
> Message-ID: <87wpp4m6n1.fsf@blackfin.pond.sub.org>
> https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03271.html
>
> I have some unfinished work towards emptying out qemu-common.h.  Need
> to find the time to finish it.
>
> [...]

YES!!!!!

Once there, we can also do other cleanups.

inclufde/sysemu/sysemu.h

have things not related at all.
I want to get rid of it on migration, because you know, we do zero
emulation there, but there are things like "runstate" that are defined
there.

I removed on that version lots of migration functionality that were
there, just from historical reasons, not because they belong there.

Later, Juan.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-06-28  9:32 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22 16:06 [Qemu-devel] [PATCH] Separate function types from opaque types in include/qemu/typedefs.h Greg Kurz
2017-06-22 16:14 ` Peter Maydell
2017-06-22 16:42   ` Greg Kurz
2017-06-22 17:03     ` Juan Quintela
2017-06-22 17:22       ` Peter Maydell
2017-06-22 17:25         ` Dr. David Alan Gilbert
2017-06-22 17:46           ` Greg Kurz
2017-06-22 17:50             ` Dr. David Alan Gilbert
2017-06-22 18:08               ` Thomas Huth
2017-06-22 18:11                 ` Peter Maydell
2017-06-22 18:34                   ` Dr. David Alan Gilbert
2017-06-22 19:23                     ` Greg Kurz
2017-06-26  9:27                       ` Dr. David Alan Gilbert
2017-06-23  7:11                   ` Markus Armbruster
2017-06-28  9:32                     ` Juan Quintela
2017-06-23  7:04         ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.