Re: [PATCH] Modernize i386 string.h

From: Richard B. Johnson
Date: Mon Jan 19 2004 - 10:06:45 EST


On Mon, 19 Jan 2004, Jeff Garzik wrote:

> Andi Kleen wrote:
> > This patch modernizes i386 string.h. It removes all the fragile i386
> > inline str* functions and just switches to gcc's builtin variants.
> > Modern gcc should generate equivalent or better code. Sometimes it
> > calls out-of-line code, in that case the standard C functions in
> > lib/string.c is used.
> [...]
> > diff -u linux-string/arch/i386/kernel/i386_ksyms.c-STRING linux-string/arch/i386/kernel/i386_ksyms.c
> > --- linux-string/arch/i386/kernel/i386_ksyms.c-STRING 2003-10-09 00:28:44.000000000 +0200
> > +++ linux-string/arch/i386/kernel/i386_ksyms.c 2004-01-18 13:26:36.479533784 +0100
> > @@ -133,6 +133,38 @@
> > EXPORT_SYMBOL(pcibios_get_irq_routing_table);
> > #endif
> >
> > +/* Export string functions. We normally rely on gcc builtin for most of these,
> > + but gcc sometimes decides not to inline them. */
> > +#undef memchr
> > +#undef strlen
> > +#undef strcpy
> > +#undef strncmp
> > +#undef strncpy
> > +#undef strchr
> > +#undef strcmp
> > +#undef strcpy
> > +#undef strcat
> > +
> > +extern size_t strlen(const char *);
> > +extern char * strcpy(char * dest,const char *src);
> > +extern int strcmp(const char * cs,const char * ct);
> > +extern void *memchr(const void *s, int c, size_t n);
> > +extern char * strcat(char *, const char *);
>
> ISTR this patch being shot down in the past...
>
> It seems suboptimal for people with ancient compilers, or for people on
> embedded 486's, doesn't it?
>
> Jeff
>

I don't think so. It helps reduce the size of the code by having
only one copy of each routine in memory rather than zillions.

If your code can't stand the overhead of the call/return, then
you put some inline code at that particular place, not everywhere!

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


-
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/