[U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible
Mike Frysinger
vapier at gentoo.org
Wed Oct 7 10:52:00 CEST 2009
On Wednesday 07 October 2009 04:44:26 Alessandro Rubini 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.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20091007/05b69532/attachment.pgp
More information about the U-Boot
mailing list