qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/4] add byteordered types to qemu.


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH 1/4] add byteordered types to qemu.
Date: Thu, 02 Oct 2008 15:15:19 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080723)

Christoph Hellwig wrote:
> Actually __CHECKER__ is set by sparse.  __CHECK_ENDIAN__ is set on the
> make command line when checking for endianess bugs.  For xfsprogs I
> defined the bitwise annotations unconditionally because we made sure
> to not have any of this warnings left (this was quite easy becaus a lot
> of the code came from the kernel and was already properly annotated)

Thanks.  I still can't see the point of __CHECK_ENDIAN__ though, as
-W(no-)bitwise should have the very same effect.  Historical reasons?

> These are the snipplets from xfsprogs that would be useful for qemu:
> 
> #ifdef __CHECKER__
> #define __bitwise     __attribute__((bitwise))
> #define __force               __attribute__((force))
> #else
> #define __bitwise
> #define __force
> #endif

> The __force is needed for the actual swab macros to turn the __bitwise
> annotated type back into the normal so it doesn't warn.  For XFS these
> conversion macros looks the same as the kernel ones:
> 
> #ifdef XFS_NATIVE_HOST
> #define cpu_to_be16(val)       ((__force __be16)(__u16)(val))
[ ... ]
> #else
> #define cpu_to_be16(val)       ((__force __be16)__swab16((__u16)(val)))
[ ... ]
> #endif
> 
> and then you define the types as __bitwise:
> 
> typedef __u16 __bitwise                __be16;
[ ... ]

I see.

> for qemu you'll need slight changes in the names, and also little
> endian variants which we don't have in XFS.

Sure.

> Note that the biggest hurdle for xfsprogs was to convince libtool
> that cgcc, the gcc wrapper for invoking sparse actually is a C compiler,
> but that should be mood for qemu.

Nevertheless it must be winded up in configure and the build system.
Shouldn't be hard though.  How fast is sparse?  Would it be sane to run
it by default in case we find cgcc installed on the system?  Or should
it better be opt-in?

> Note that sparse will probably complain about a lot of things in
> qemu, so you'll have to add a lot -Wno-foo options in addition to
> -Wbitwise.

Even -Wbitwise will probably generate tons of warnings initially.

cheers,
  Gerd




reply via email to

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