endian-swapping

David Edelsohn dje at watson.ibm.com
Sat Dec 4 12:56:23 EST 1999


>>>>> Hollis R Blanchard writes:

Hollis> On Fri, 3 Dec 1999, David Edelsohn wrote:
>> 
>> Linux already provides macros like le16_to_cpu(), etc. for this. 

Hollis> For the sake of someone (like me) who doesn't know how to use these, can you
Hollis> give an example?

	See drivers/net/pcnet32.c for one example of its use.  There are
no #ifdef's like NetBSD uses.  le16_to_cpu() is a no-op on LE machines, so
one uses it directly like 

short x = le16_to_cpu(dev_flag);

Hollis> Also, the macros are in which header? I'm having trouble finding them too...

	The macros seem to be included via <asm/bitops.h> which then
include <linux/byteorder/big_endian.h> (for example).

David

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list