Endian/__BYTE_ORDER question

Joakim Tjernlund joakim.tjernlund at transmode.se
Fri Feb 12 03:21:52 EST 2010


>
> I am getting confused about on how to test for Endian in the kernel code. In user
> space one uses #if __BYTE_ORDER == __LITTLE_ENDIAN or #if __BYTE_ORDER == __BIG_ENDIAN
>
> I can see lots of kernel headers using this test too, but it doesn't seem
> to be an arch specific file #defining __BYTE_ORDER. Instead I find files like:
>  arch/alpha/math-emu/sfp-util.h
>  arch/powerpc/include/asm/sfp-machine.h
>  arch/s390/include/asm/sfp-util.h
>  arch/sh/math-emu/sfp-util.h
>
> How is this supposed to work?
>
>     Jocke

Figured I should mention that a simple:
#include <asm/byteorder.h>

#ifndef __BYTE_ORDER
# error __BYTE_ORDER is not defined
#endif

Doesn't work.

    Jocke



More information about the Linuxppc-dev mailing list