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 14:46:41 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080723)

Christoph Hellwig wrote:

>> +typedef uint16_t le16;
>> +typedef uint32_t le32;
>> +typedef uint64_t le64;
>> +typedef uint16_t be16;
>> +typedef uint32_t be32;
>> +typedef uint64_t be64;
> 
> Any chance you could add sparse __bitwise__ declarations so one could
> use spare to check for using these types correctly?

Is there any good documentation on that?

Looking at the linux kernel sources I find the bitwise stuff depend on
the __CHECKER__ and __CHECK_ENDIAN__ defines.  I can't find references
to these in the sparse man page and sparse FAQ (sparse 0.4.1 as shipped
by fedora 9).

I can somehow guess what these two defines do.  __CHECKER__ probably is
set by sparse, and __CHECK_ENDIAN__ by the -Wbitwise switch.  But I
can't see any obvious reason why include/linux/types.h defines both
__bitwise__ and __bitwise.  I'd simply use something along the lines ...

  #if defined(__CHECKER__) && defined(__CHECK_ENDIAN__)
  # define __bitwise__ __attribute__((bitwise))
  #else
  # define __bitwise__
  #endif

  typedef uint16_t __bitwise__ le16;
  [ ... ]

cheers,
  Gerd




reply via email to

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