Endianness and comparing IP's

Iain Sandoe iain at sandoe.co.uk
Sun Jan 7 10:05:05 EST 2001


Sat, Jan 6, 2001, drscholl wrote...
[...]
>> probably (but it wouldn't be difficult to check that anyway).
> Yes, I did verify that they are all unsigned int, not just relying on
> that.  :-)

hmmm. I suppose that the literals in the macro are int by definition?

> /* convert the bytes of a 32-bit integer to little endian */
> #define BSWAP32(c)
> ((c>>24)&0xff)|((c>>8)&0xff00)|((c<<8)&0xff0000)|(c<<24)
>> (or are you convinced it is OK?)
> Seems to work fine under Solaris, otherwise nobody would be able to
> download anything because the IP address would be reversed.

works OK for me too under linuxppc (with default compiler options - got
anything weird specified?).

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





More information about the Linuxppc-dev mailing list