Hi Andrew.
On Mon, 29 Apr 2002 22:50:00 -0400, Andrew Patrikalakis wrote:
>
>Hello all (again).
>
>I have updated the Newton Streamed Object Decoder. It is now a FULLY
>FUNCTIONAL
>decoder for streamed Newton Objects (but still only on the Mac because of
>f***ing
>endian-ness, someone PLEASE look at byte_order.c and help me with that!).
Why you do this?
#ifdef LITTLE_ENDIAN
char *s;
s = dest;
#endif /* LITTLE_ENDIAN */
memcpy(dest, &l, 4);
#ifdef LITTLE_ENDIAN
(*s) = ((((*s) << 24) & 0xFF000000) | (((*s) << 8) &
0x00FF0000) | (((*s) >> 8) & 0x0000FF00) | (((*s) >> 24) &
0x000000FF));
#endif /* LITTLE_ENDIAN */
I would do it like this:
#ifdef LITTLE_ENDIAN
char s[4];
#endif /* LITTLE_ENDIAN */
memcpy(dest, &l, 4);
#ifdef LITTLE_ENDIAN
s[0] = dest[3];
s[1] = dest[2];
s[2] = dest[1];
s[3] = dest[0];
memcpy(dest, s, 4);
#endif /* LITTLE_ENDIAN */
How do you like this?
Jochen
-- Read the List FAQ/Etiquette: http://www.newtontalk.net/faq.html Read the Newton FAQ: http://www.guns-media.com/mirrors/newton/faq/ This is the NewtonTalk mailing list - http://www.newtontalk.net
This archive was generated by hypermail 2.1.2 : Sun May 05 2002 - 14:05:32 EDT