[RUSSYLKI] __IEEE_*_ENDIAN vs. BYTE_ORDER
Artem B. Bityuckiy
abityuckiy@yandex.ru
Wed Apr 28 16:30:00 GMT 2004
Ralf Corsepius wrote:
> Hi,
>
> Newlib's sys/param.h applies __IEEE_*_ENDIAN (from machine/ieeefp.h) to
> define BYTE_ORDER.
>
> AFAIU, __IEEE_*_ENDIAN denotes the floating point endianess, only, which
> doesn't necessarily match with a CPU's general endianess.
>
>
> E.g. some arm-CPUs seem to use __IEEE_BIG_ENDIAN, while actually being
> little endian targets.
>
> On these targets newlib's sys/param.h results into
> #define __IEEE_BIG_ENDIAN
> #define BYTE_ORDER BIG_ENDIAN
>
> even for little endian arm targets, while I think
> #define __IEEE_BIG_ENDIAN
> #define BYTE_ORDER LITTLE_ENDIAN
>
> would have been correct.
>
> I.e. I suspect newlib's sys/param.h to be "illegally" using
> __IEEE_*_ENDIAN to setup BYTE_ORDER. I am wrong or right?
>
> Ralf
>
I agree.
I've met problems with that. For my arm-elf target i had BYTE_ORDER =
BIG_ENDIAN when I had -m little-endian gcc option. This is because of:
1. We rely on floating point endianess to get integers endianess.
2. Floating point endianess isn't always equivalent to integers
endianess (Arm may gave mixed endianess for floating point).
I think BYTE_ORDER macro must relate to integers endian. For floating
point endianess we should use __IEEE_* macros.
--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.
More information about the Newlib
mailing list