Re: byteorder mess
Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
Sat, 6 Dec 1997 14:46:08 +0100 (MET)
On 5 Dec 1997, Jes Sorensen wrote:
> Linus> On 5 Dec 1997, Jes Sorensen wrote:
> >> Which will simply turn into `x'. This will break libc if you build
> >> it against these headers!
>
> Linus> Why? ((unsigned long)(__u32)(x)) is the _correct_ answer on a
> Linus> big-endian machine. How could that break libc?
>
> Linus> If libc internally tries to do the htonl() functions and the
> Linus> above breaks the function declaration, then libc is _wrong_.
>
> I have been through my archives, without luck, hoping to find the
> patch with the explanation from Andreas. However, what I did find was
> an old posting from a guy having problems with libc-5.3.12 missing the
> ntoh and hton functions.
The problem was that libc called the functions again, causing infinite
recursion. And this showed up only if you compiled a program without
optimization. With optimization the correct code was expanded inline. This was
fixed at in m68k/2.0.8 or something like that (at the Oldenburg '96 Linux/m68k
hackers meeting).
BTW, I think the `VAX' reference is wrong. Traditionally it is called `PDP
endiannes', so it predates the `PDP-11 with Virtual Address eXtension',
commonly known by `VAX'.
Greetings,
Geert
--
Geert Uytterhoeven Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/{m68k~Amiga,PPC~CHRP} http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium