Re: [PATCH] Modernize i386 string.h

From: Andi Kleen
Date: Mon Jan 19 2004 - 20:47:12 EST


On Mon, Jan 19, 2004 at 04:49:54PM -0800, Richard Henderson wrote:
> On Sun, Jan 18, 2004 at 09:09:19PM +0100, Andi Kleen wrote:
> > +#define __HAVE_ARCH_MEMCPY 1
> > +extern void *__memcpy(void *to, const void *from, size_t len);
> > +#define memcpy(dst,src,len) \
> > + ({ size_t __len = (len); \
> > + void *__ret; \
> > + if (__builtin_constant_p(len) && __len >= 128) \
> > + __ret = __memcpy((dst),(src),__len); \
> > + else \
> > + __ret = __builtin_memcpy((dst),(src),__len); \
> > + __ret; })
>
> Why not just __builtin_memcpy? Or indeed, why bother defining
> anything at all, since the compiler will infer __builtin_memcpy
> from the external symbol memcpy.

I was considering that when I moved the code over from x86-64.

On x86-64 (in gcc 3.1 timeframe) I did it originally this way
because memcpy didn't have this "use external for big copies" logic.
I wasn't sure if gcc 3.3 handles it now correctly. If you can
confirm that it does I will happily remove it.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/