endian-swapping

Hollis R Blanchard hollis+ at andrew.cmu.edu
Sat Dec 4 12:13:09 EST 1999


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

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

#include <endian.h>

#ifdef __BIG_ENDIAN
    cpu_to_le16(blah);
#endif

I don't know which headers are supposed to be used for this. endian.h, for
example, does a #define __BIG_ENDIAN 4321, so __BIG_ENDIAN should *always* be
defined... so that doesn't seem like the right header to include... but lots
of drivers do that exact #ifdef test.

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

-Hollis


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





More information about the Linuxppc-dev mailing list