[uClibc] ldso 0.9.21, libstdc++ crashes on PowerPC GCC 3.3.1

Joakim Tjernlund joakim.tjernlund at lumentis.se
Mon Oct 6 14:18:13 UTC 2003


> > On Mon Oct 06, 2003 at 09:20:09AM +0200, Joakim Tjernlund wrote:
> > > I browsed the uClib WWW CVS to find memcpy and friends and I did not find them.
> > 
> > uClibc/libc/string/wstring.c
> 
> I found a Wmemcpy. I suppose this is what you ment. It is very slow.
> 
> > 
> > > I suspect these are impl. in C somewhere. Is there a reason why these aren't in
> > > assembler? It would be easy to rip these from the kernel.
> > 
> > The kernel is GPL while uClibc is LGPL.  So while we can borrow
> > code from things like glibc, we cannot borrow kernel code.
> 
> Ahh, I see.
> 
> Maybe this memcpy will do, which is inspired by the kernel memcpy but I wrote
> it myself as a test.
[SNIP]

Here is a C version which generates assembler which is very close
to the memcpy in the linux kernel for PPC(gcc 2.95.3).
Not tested, but compiles. What do you think?

 Jocke

void *memcpy(void *to, const void *from, size_t n)
{
	unsigned long rem, chunks, tmp1, tmp2;
	void *tmp_to;

	chunks = n / 8;
	from -= 4;
	tmp_to = to - 4;
	if (!chunks)
		goto lessthan8;
	rem = (unsigned long )tmp_to % 4;
	if (rem)
		goto align;
 copy_chunks:
	do {
		tmp1 = *(unsigned long *)(from+4);
		from += 8;
		tmp2 = *(unsigned long *)from;
		*(unsigned long *)(tmp_to+4) = tmp1;
		tmp_to += 8;
		*(unsigned long *)tmp_to = tmp2;
	} while (--chunks);
 lessthan8:
	n = n % 8;
	if (n >= 4) {
		*++(unsigned long *)tmp_to = *++(unsigned long *)from;
		n = n-4;
	}
	if (!n ) return to;
	from += 3;
	tmp_to += 3;
	do {
		*++(unsigned char *)tmp_to = *++(unsigned char *)from;
	} while (--n);
	
	return to;
 align:
	rem = 4 - rem;
	n = n-rem;
	do {
		*(unsigned char *)(tmp_to+4) = *(unsigned char *)(from+4);
		++from;
		++tmp_to;
	} while (--rem);
	chunks = n / 8;
	if (chunks)
		goto copy_chunks;
	goto lessthan8;
}




More information about the uClibc mailing list