Re: Cleanup possibility in asm-i386/string.h



Hi,

On Tue, 7 Feb 2006, Andi Kleen wrote:

If you feel the need to remove some more code: Now that gcc 2.95 isn't supported
anymore there isn't really a need to keep the handwritten inline string functions
in asm-i386/string.h around. Just declaring them as normal externs will cause
gcc to use its builtin expansions, which are typically better than these old inline
functions with inline assembly.

For out of line the C versions in lib/string.c can be used (by not setting __ARCH_*)
x86-64 did it like this forever and I guess it would be valuable cleanup for i386 too.

The only problem is that we compile with -ffreestanding which implies
-fno-builtin, so just declaring them as normal externs is not enough and
you have to something like this:

#define __HAVE_ARCH_MEMSET
extern void *memset(void *, int, __kernel_size_t);
#define memset(d, c, n) __builtin_memset(d, c, n)

(BTW you do this already in x86-64.)

Another problem here is because of -fno-builtin it's not easy to use the
generic functions as fallback. x86-64 basically does this:

#define strlen __builtin_strlen
size_t strlen(const char * s);

#ifndef __HAVE_ARCH_STRLEN
extern __kernel_size_t strlen(const char *);
#endif

This means you define a prototype for the builtin function and not for the
normal function. I'm not sure this is really intended.

bye, Roman
-
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/



Relevant Pages

  • Re: Cleanup possibility in asm-i386/string.h
    ... Just declaring them as normal externs will cause ... gcc to use its builtin expansions, which are typically better than these old inline ... What good would be a prototype for a symbol that is defined to a different symbol? ...
    (Linux-Kernel)
  • Re: Load-time evaluation of compound form operators.
    ... finer-grained way of declaring things than NOTINLINE and INLINE. ... NOTINLINE says pretty much "assume nothing, you need to look it up every ... function STATIC and then redefine it anyway, ...
    (comp.lang.lisp)
  • Re: Load-time evaluation of compound form operators.
    ... finer-grained way of declaring things than NOTINLINE and INLINE. ... NOTINLINE says pretty much "assume nothing, you need to look it up every ... this declaration would enable the compiler to assume as much ...
    (comp.lang.lisp)
  • Re: Disadvantage of using inline
    ... Declaring a function as 'inline' never meant that is has no "independent ... The decision to inline a call is made by the compiler on a per-call ... >> machines, there are so few registers that tying one up is stupid), ...
    (comp.lang.c)
  • Re: about inline functions
    ... Yes and no. 'inline' is just a hint to the compiler. ... A static function, often doesn't have to be an actual function - it could be in-lined at each call, and a good optimizing compiler will do just that, taking advantage of the as-if rule. ... However, if you have a function for which 'inline' is a good idea, it's often the case that simply declaring it 'static' without the 'inline' keyword is sufficient to allow the compiler to perform this optimization. ...
    (comp.lang.c)