00001 #ifndef __STRINGEXPAND_H_ 00002 #define __STRINGEXPAND_H_ 00003 00004 #include <nlibc.h> 00005 #include <alloca.h> 00006 #include <string/strlen.h> 00007 00012 #if !defined(__cflow_processed) || defined(_uses_stringexpand_stringexpand_h) 00013 inline char * stringexpand( const char *str, int len ) { 00014 int *estr = (int *)alloca((len+1)*16 ); 00015 unsigned *p = (unsigned *) str; 00016 int mshift = -8; 00017 int a, c=0, c2=8; 00018 00019 if( ! (a=*p) ) return 0; 00020 do { 00021 unsigned mask = 0xff; 00022 unsigned vshift = 0; 00023 do { 00024 int hi,lo; 00025 unsigned u = (a & mask); 00026 u = u>>vshift; 00027 asm("\tlutcross.L %0 %1\n\tatr.H %0 $ZERO" : "=r" (hi) : "r" (u)); 00028 asm("\tlutmove.L %0 %1\n\tatr.H %0 $ZERO" : "=r" (lo) : "r" (u)); 00029 estr[c++] = lo; 00030 where( c2 <= len ) { 00031 estr[c2++] = hi; 00032 } 00033 mask >>= mshift; 00034 vshift += 8; 00035 } while( mask ); 00036 c += 8; 00037 c2 += 8; 00038 a = *(++p); 00039 } while( a ); 00040 return (char *)estr; 00041 } 00042 #endif 00043 00044 #endif // __STRINGEXPAND_H_