Re: Endianness and comparing IP's

3 messages, 3 authors, 2001-01-08 · open the first message on its own page

Re: Endianness and comparing IP's

From: Iain Sandoe <hidden>
Date: 2001-01-06 23:37:24

/* 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)
 #define BSWAP32(c) \
(((c>>24)&0xff)|((c>>8)&0xff00)|((c<<8)&0xff0000)|(c<<24))


will work as you expect it too... ;-)

precedence is a funny thing...

Iain.

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

Re: Endianness and comparing IP's

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2001-01-08 07:16:05

On Sat, 6 Jan 2001, Iain Sandoe wrote:
quoted
/* 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)
 #define BSWAP32(c) \
(((c>>24)&0xff)|((c>>8)&0xff00)|((c<<8)&0xff0000)|(c<<24))


will work as you expect it too... ;-)

precedence is a funny thing...
Similarly, replace `c' by `(c)'.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


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

Re: Endianness and comparing IP's

From: alex avriette <hidden>
Date: 2001-01-08 13:20:23

Thank you all. The problem has been solved. solution (as per Iain and
Geert):

#define BSWAP32(c)
((((c)>>24)&0xff)|(((c)>>8)&0xff00)|(((c)<<8)&0xff0000)|((c)<<24))


thanks again.
alex


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help