qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 1/2] block/vxhs.c: Add support for a new bloc


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v6 1/2] block/vxhs.c: Add support for a new block device type called "vxhs"
Date: Tue, 15 Nov 2016 19:20:26 +0000
User-agent: Mutt/1.7.1 (2016-10-04)

On Tue, Nov 15, 2016 at 11:00:16PM +0800, Fam Zheng wrote:
> On Tue, 11/15 14:45, Stefan Hajnoczi wrote:
> > On Tue, Nov 15, 2016 at 08:44:17PM +0800, Fam Zheng wrote:
> > > On Tue, 11/15 10:18, Stefan Hajnoczi wrote:
> > > > Fam, Markus: Unfortunately neither the clean-includes script nor its
> > > > patch series cover letter explains *why* osdep.h should be included
> > > > before system headers.
> > > 
> > > I don't know Peter's exact intention either, but AFAICT it is about the 
> > > few
> > > quirks in osdep.h:
> > > 
> > > 
> > > /* Older versions of C++ don't get definitions of various macros from
> > >  * stdlib.h unless we define these macros before first inclusion of
> > >  * that system header.
> > >  */
> > > #ifndef __STDC_CONSTANT_MACROS
> > > #define __STDC_CONSTANT_MACROS
> > > #endif
> > > #ifndef __STDC_LIMIT_MACROS
> > > #define __STDC_LIMIT_MACROS
> > > #endif
> > > #ifndef __STDC_FORMAT_MACROS
> > > #define __STDC_FORMAT_MACROS
> > > #endif
> > > 
> > > /* The following block of code temporarily renames the daemon() function 
> > > so the
> > >  * compiler does not see the warning associated with it in stdlib.h on OSX
> > >  */
> > > #ifdef __APPLE__
> > > #define daemon qemu_fake_daemon_function
> > > #include <stdlib.h>
> > > #undef daemon
> > > extern int daemon(int, int);
> > > #endif
> > > 
> > > <...>
> > > 
> > > 
> > > /* Mac OSX has a <stdint.h> bug that incorrectly defines SIZE_MAX with
> > >  * the wrong type. Our replacement isn't usable in preprocessor
> > >  * expressions, but it is sufficient for our needs. */
> > > #if defined(HAVE_BROKEN_SIZE_MAX) && HAVE_BROKEN_SIZE_MAX
> > > #undef SIZE_MAX
> > > #define SIZE_MAX ((size_t)-1)
> > > #endif
> > 
> > This is exactly the kind of stuff we should not be doing to the libqnio
> > header file!
> > 
> > Those redefinitions are useful for QEMU code.  They should not be done
> > to third-party system headers though.
> 
> But we still want to include osdep.h before libqnio pulls in stdint.h. If we
> don't make osdep.h the very first, that cannot be guaranteed.

Thanks, that makes sense!

I'll add a comment to clean-includes with this explanation of why
osdep.h must go before system headers.

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]