Endianness and comparing IP's

drscholl drscholl at users.sourceforge.net
Sun Jan 7 09:39:24 EST 2001


On Sat, Jan 06, 2001 at 10:28:48PM +0000, Iain Sandoe wrote:
> > All of the ints in question are unsigned, so there isn't an issue of
> > conversion (I beleive gcc -W -Wall -pedantic would have warned if you
> > tried to do a comparison of different types, anyway).
>
> 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.  :-)

> What is the code for the BSWAP32 macro?
> ...and what asm does it produce?
> (or does it use __asm() statements?)

/* 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.

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





More information about the Linuxppc-dev mailing list