lkml.org 
[lkml]   [1999]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectDesign bug in include/asm*/string.h
Reading the gcc documentation (gcc-2.7.2 and egcs-1.1.2) I found:

<<`-fno-builtin'
<< Don't recognize builtin functions that do not begin with two
<< leading underscores. Currently, the functions affected include
<< `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
<< `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
<< `strlen'.
<<
<< GCC normally generates special code to handle certain builtin
<< functions more efficiently; for instance, calls to `alloca' may
<< become single instructions that adjust the stack directly, and
<< calls to `memcpy' may become inline copy loops. The resulting
<< code is often both smaller and faster, but since the function
<< calls no longer appear as such, you cannot set a breakpoint on
<< those calls, nor can you change the behavior of the functions by
<< linking with a different library.
<<
<< The `-ansi' option prevents `alloca' and `ffs' from being builtin
<< functions, since these functions do not have an ANSI standard
<< meaning. >>

And compiler make really this!
Also some of the optimized code in linux/include/asm*/string.h are never
used!

Possible work-around:
1) use the option -fno-builtin in arch/*/Makefile

2) use at top of include/asm*/string.h:
#define strcmp linux_strcmp
...
This allows to mix the compiler/kernel optimized functions
I prefer the second work-around

Notes:
1) We must carefully check if linux string functions work,
before to make any change.
2) The compiler handles the code better on constant arguments
3) For each arch/processor we must choice the better code
4) Extra notes:
- Remove include/asm-i386/string-486.h
- Splits the file libs/string.c, so that linker can discard
some functions.
- On libs/string.c:
gcc allow to link 'void' files (void=without external/global
symbols), also the "char * ___strtok = NULL;" can be moved
within the "#ifndef __HAVE_ARCH_STRTOK" block.


Giacomo Catenazzi : < gcatenaz @ g26.ethz.ch >

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

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.039 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site