Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756423AbXJIWMP (ORCPT ); Tue, 9 Oct 2007 18:12:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753968AbXJIWME (ORCPT ); Tue, 9 Oct 2007 18:12:04 -0400 Received: from khc.piap.pl ([195.187.100.11]:54714 "EHLO khc.piap.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752833AbXJIWMB (ORCPT ); Tue, 9 Oct 2007 18:12:01 -0400 To: Timur Tabi Cc: Lennart Sorensen , Anton Altaparmakov , Jan Engelhardt , Linux Kernel Mailing List Subject: Re: __LITTLE_ENDIAN vs. __LITTLE_ENDIAN_BITFIELD References: <4706822D.4070509@freescale.com> <470691EB.7020209@freescale.com> <4706A842.9030507@freescale.com> <20071009174623.GC4003@csclub.uwaterloo.ca> <470BC0D5.70305@freescale.com> <470BCEFC.9060302@freescale.com> <470BDA3A.1060809@freescale.com> From: Krzysztof Halasa Date: Wed, 10 Oct 2007 00:11:59 +0200 In-Reply-To: <470BDA3A.1060809@freescale.com> (Timur Tabi's message of "Tue, 09 Oct 2007 14:44:58 -0500") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1237 Lines: 29 Timur Tabi writes: > I think when the PowerPC is running in little-endian mode, that might > be the case. It needs to be able to write a byte in big-endian mode, > and then read that byte back in little-endian mode and have it be the > same byte. But this is exactly what excludes changing bit orders :-) There are other CPU types which can work both LE and BE. If you write 0x12345678 and switch endianness you get 0x78563412, but the individual bits are still in the same (natural) order. In the kernel, to convert from BE to LE or vice versa you need something like swab32 (assuming 32-bit ints). It doesn't change the order of the individual bits, it only swaps the (4 in this case) bytes ("lanes" for hw swapping, PCI etc). If you, for example, write an 8-bit integer in BE mode and want it back in LE mode, you have to XOR the address with 0x3, but the value already comes in the same natural bit order. Of course swab32 will do as well. -- Krzysztof Halasa - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/