I'm thinking of making strlen() faster (by checking longword at a
time, nice trick from glibc). So I looked at asm/string and found:
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
* byte string ops are faster than doing it by hand
* (MUCH faster on a Pentium).
~~~~~~~
This comment is little bit strange. Should not be 'PPro' be written
here?
*
* Also, the byte strings actually work correctly. Forget
* the i486 routines for now as they may be broken..
*/
#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
#include <asm/string-486.h>
#else
Maybe it would be nice to check i486 routines, or drop them
completely... [Unfortunately, gcc inline is _so_ confusing for me that
I do not dare...]
Also, here is code for strlen():
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di");
return __res;
I wonder if __volatile__ is really neccessary there. It could have
pretty bad impact on performance.
Pavel
-- I'm really pavel@atrey.karlin.mff.cuni.cz. Pavel Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).