[U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible
Wolfgang Denk
wd at denx.de
Wed Oct 7 11:30:50 CEST 2009
Dear Mike Frysinger,
In message <200910070452.02225.vapier at gentoo.org> you wrote:
>
> > --- a/lib_generic/string.c
> > +++ b/lib_generic/string.c
> > @@ -449,7 +449,16 @@ char * bcopy(const char * src, char * dest, int count)
> > void * memcpy(void * dest,const void *src,size_t count)
> > {
> > char *tmp = (char *) dest, *s = (char *) src;
> > + u32 *d32 = (u32 *)dest, *s32 = (u32 *) src;
> >
> > + /* if both are aligned, use 32-bit copy */
> > + if ( (((int)dest & 3) | ((int)src & 3) | (count & 3)) == 0 ) {
>
> while 64bit isnt in today, might as well avoid unclean code from the start
> when possible. in other words, used "unsigned int" rather than "u32" and cast
> to "unsigned long" rather than "int".
>
> > + count /= 4;
>
> count >>= 2 ? although gcc probably optimizes this properly.
Neither one nor the other.
This should become
count /= sizof(int);
then.
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 at denx.de
When all is said and done, more is said than done.
More information about the U-Boot
mailing list