User level Macros for Endianess

Gabriel Paubert paubert at iram.es
Wed Jan 12 20:31:45 EST 2000




On 12 Jan 2000, Jesper Skov wrote:

> #include <asm/byteorder.h>
> 
> then use __le32_to_cpu and friends (see
> /usr/include/linux/byteorder/generic.h)
> 
> I'm not sure if that's the Proper Way(TM) to do it from user land
> though.

No, it's very different between application and kernel code (unfortunately
since this forced me to write 2 very different vme.h include files for VME
systems, it's not only a simple cp). Under Linux, asm/byteorder.h is the
right way to get the correct macros, and either LITTLE_ENDIAN or
BIG_ENDIAN is defined.

>From userland both are defined and then BYTE_ORDER is set to one of these
(strange architecture might even have a byte order which is neither like
the PDP) so the check is #if __BYTE_ORDER==__BIG_ENDIAN ...

	Gabriel.


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





More information about the Linuxppc-dev mailing list