
8 Oct
2009
8 Oct
'09
10:37 a.m.
Dear Alessandro Rubini,
In message 20091008074114.GA30203@mail.gnudd.com you wrote:
Since int is 32 also on 64bit systems, I used unsigned long.
Note that this is not guaranteed, though. It could be 64 bit as well.
/* do it one word at a time (32 bits or 64 bits) if possible */ if ( ((count | (int)s) & (sizeof(long) - 1)) == 0) { count /= sizeof(long); cl = (c & 0xff) | ((c & 0xff) << 8); cl |= cl << 16; if (sizeof(long) > 4) cl |= cl << 32;
How about:
cl = 0; for (i=0; i<sizeof(long); ++i) { cl <<= 8; cl |= c & 0xff; }
GCC optimization will do the rest...
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
If I don't document something, it's usually either for a good reason,
or a bad reason. In this case it's a good reason. :-)
- Larry Wall in 1992Jan17.005405.16806@netlabs.com