From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KlNZy-0001kS-Ov for qemu-devel@nongnu.org; Thu, 02 Oct 2008 08:46:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KlNZw-0001jf-Sq for qemu-devel@nongnu.org; Thu, 02 Oct 2008 08:46:50 -0400 Received: from [199.232.76.173] (port=58455 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KlNZw-0001jY-Im for qemu-devel@nongnu.org; Thu, 02 Oct 2008 08:46:48 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59016) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KlNZv-0004px-Uq for qemu-devel@nongnu.org; Thu, 02 Oct 2008 08:46:48 -0400 Message-ID: <48E4C2B1.7010108@redhat.com> Date: Thu, 02 Oct 2008 14:46:41 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/4] add byteordered types to qemu. References: <1222870375-13489-1-git-send-email-kraxel@redhat.com> <20081002082137.GA25959@lst.de> In-Reply-To: <20081002082137.GA25959@lst.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org 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