qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* tidying up osdep.h
@ 2021-04-14 19:17 Peter Maydell
  2021-04-15  8:59 ` Philippe Mathieu-Daudé
  2021-04-15  9:10 ` Markus Armbruster
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2021-04-14 19:17 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Paolo Bonzini, Daniel P. Berrange, Markus Armbruster

(cc'ing people related to the recent 'extern "C"' patches and also
randomly Markus as somebody who's had opinions on header cleanups
in the past...)

osdep.h as it stands today is a mix of two things:
 (1) it has the "must be included by everybody" items:
   (a) config-host.h, poison.h, compiler.h
   (b) things which must be done before any system header is included
       (like defining __STDC_CONSTANT_MACROS or WIN32_LEAN_AND_MEAN)
   (c) includes of system headers which we need to then fix up for
       portability issues (eg redefining assert on mingw, defining
       fallback versions of missing macros)
 (2) it has declarations for a library of QEMU functions, some of which
     typically wrap and abstract away OS specifics (like qemu_create(),
     qemu_unlink()), and some of which seem to have just been dumped
     in here for convenience (like qemu_hw_version())

Every file needs (1), which is why we mandate osdep.h as the first
include; most files don't need a lot of the things in (2) (for instance
qemu_hw_version() is used in just half a dozen .c files). Is it worth
trying to split some of the type (2) items out into their own header files?

I suspect that the advantages would be primarily just making osdep.h
a bit clearer to read and less of an "attractive nuisance" for new
additions; I imagine the bulk of the extra compilation time represented
by osdep.h is going to be because it pulls in dozens of system
headers, most of which are going to be required under heading (1).

thanks
-- PMM


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

* Re: tidying up osdep.h
  2021-04-14 19:17 tidying up osdep.h Peter Maydell
@ 2021-04-15  8:59 ` Philippe Mathieu-Daudé
  2021-04-15 14:55   ` Markus Armbruster
  2021-04-15  9:10 ` Markus Armbruster
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15  8:59 UTC (permalink / raw)
  To: Peter Maydell, QEMU Developers
  Cc: Paolo Bonzini, Daniel P. Berrange, Markus Armbruster

On 4/14/21 9:17 PM, Peter Maydell wrote:
> (cc'ing people related to the recent 'extern "C"' patches and also
> randomly Markus as somebody who's had opinions on header cleanups
> in the past...)
> 
> osdep.h as it stands today is a mix of two things:
>  (1) it has the "must be included by everybody" items:
>    (a) config-host.h, poison.h, compiler.h
>    (b) things which must be done before any system header is included
>        (like defining __STDC_CONSTANT_MACROS or WIN32_LEAN_AND_MEAN)
>    (c) includes of system headers which we need to then fix up for
>        portability issues (eg redefining assert on mingw, defining
>        fallback versions of missing macros)
>  (2) it has declarations for a library of QEMU functions, some of which
>      typically wrap and abstract away OS specifics (like qemu_create(),
>      qemu_unlink()), and some of which seem to have just been dumped
>      in here for convenience (like qemu_hw_version())
> 
> Every file needs (1), which is why we mandate osdep.h as the first
> include; most files don't need a lot of the things in (2) (for instance
> qemu_hw_version() is used in just half a dozen .c files). Is it worth
> trying to split some of the type (2) items out into their own header files?
> 
> I suspect that the advantages would be primarily just making osdep.h
> a bit clearer to read and less of an "attractive nuisance" for new
> additions; I imagine the bulk of the extra compilation time represented
> by osdep.h is going to be because it pulls in dozens of system
> headers, most of which are going to be required under heading (1).

What about:

- extract qemu_hw_version() to "qemu/legacy_api.h"?

- extract (1) from osdep.h as osinc.h (because described as
  "OS includes and handling of OS dependencies")?
  Or KISS as "qemu-first-include.h"...

- osdep.h now contains the declarations for osdep.c

Regards,

Phil.



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

* Re: tidying up osdep.h
  2021-04-14 19:17 tidying up osdep.h Peter Maydell
  2021-04-15  8:59 ` Philippe Mathieu-Daudé
@ 2021-04-15  9:10 ` Markus Armbruster
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2021-04-15  9:10 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Paolo Bonzini, Daniel P. Berrange, QEMU Developers

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

> (cc'ing people related to the recent 'extern "C"' patches and also
> randomly Markus as somebody who's had opinions on header cleanups
> in the past...)
>
> osdep.h as it stands today is a mix of two things:
>  (1) it has the "must be included by everybody" items:
>    (a) config-host.h, poison.h, compiler.h
>    (b) things which must be done before any system header is included
>        (like defining __STDC_CONSTANT_MACROS or WIN32_LEAN_AND_MEAN)
>    (c) includes of system headers which we need to then fix up for
>        portability issues (eg redefining assert on mingw, defining
>        fallback versions of missing macros)
>  (2) it has declarations for a library of QEMU functions, some of which
>      typically wrap and abstract away OS specifics (like qemu_create(),
>      qemu_unlink()), and some of which seem to have just been dumped
>      in here for convenience (like qemu_hw_version())

It's such a convenient dumping ground :)

> Every file needs (1), which is why we mandate osdep.h as the first
> include; most files don't need a lot of the things in (2) (for instance
> qemu_hw_version() is used in just half a dozen .c files). Is it worth
> trying to split some of the type (2) items out into their own header files?
>
> I suspect that the advantages would be primarily just making osdep.h
> a bit clearer to read and less of an "attractive nuisance" for new
> additions; I imagine the bulk of the extra compilation time represented
> by osdep.h is going to be because it pulls in dozens of system
> headers, most of which are going to be required under heading (1).

I agree that keeping it focused on (1) would be cleaner, and that such a
cleanup probably won't speed up builds.  Regarding your question whether
the cleanup is worth the bother: I guess if somebody posts patches, it
is.



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

* Re: tidying up osdep.h
  2021-04-15  8:59 ` Philippe Mathieu-Daudé
@ 2021-04-15 14:55   ` Markus Armbruster
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2021-04-15 14:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers, Paolo Bonzini

Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 4/14/21 9:17 PM, Peter Maydell wrote:
>> (cc'ing people related to the recent 'extern "C"' patches and also
>> randomly Markus as somebody who's had opinions on header cleanups
>> in the past...)
>> 
>> osdep.h as it stands today is a mix of two things:
>>  (1) it has the "must be included by everybody" items:
>>    (a) config-host.h, poison.h, compiler.h
>>    (b) things which must be done before any system header is included
>>        (like defining __STDC_CONSTANT_MACROS or WIN32_LEAN_AND_MEAN)
>>    (c) includes of system headers which we need to then fix up for
>>        portability issues (eg redefining assert on mingw, defining
>>        fallback versions of missing macros)
>>  (2) it has declarations for a library of QEMU functions, some of which
>>      typically wrap and abstract away OS specifics (like qemu_create(),
>>      qemu_unlink()), and some of which seem to have just been dumped
>>      in here for convenience (like qemu_hw_version())
>> 
>> Every file needs (1), which is why we mandate osdep.h as the first
>> include; most files don't need a lot of the things in (2) (for instance
>> qemu_hw_version() is used in just half a dozen .c files). Is it worth
>> trying to split some of the type (2) items out into their own header files?
>> 
>> I suspect that the advantages would be primarily just making osdep.h
>> a bit clearer to read and less of an "attractive nuisance" for new
>> additions; I imagine the bulk of the extra compilation time represented
>> by osdep.h is going to be because it pulls in dozens of system
>> headers, most of which are going to be required under heading (1).
>
> What about:
>
> - extract qemu_hw_version() to "qemu/legacy_api.h"?
>
> - extract (1) from osdep.h as osinc.h (because described as
>   "OS includes and handling of OS dependencies")?
>   Or KISS as "qemu-first-include.h"...

For what it's worth, the autoconf convention is to call it "config.h".

> - osdep.h now contains the declarations for osdep.c
>
> Regards,
>
> Phil.



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

end of thread, other threads:[~2021-04-15 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 19:17 tidying up osdep.h Peter Maydell
2021-04-15  8:59 ` Philippe Mathieu-Daudé
2021-04-15 14:55   ` Markus Armbruster
2021-04-15  9:10 ` Markus Armbruster

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).