Subject: Re: copystr
To: None <>
From: David Laight <>
List: tech-kern
Date: 09/03/2002 14:54:50
> This isn't true on all architectures.  On NetBSD/arm, for instance, memcpy()
> and memmove() are identical (from sys/lib/libkern/arch/arm/memcpy.S):
> ENTRY(memcpy)
> ENTRY_NP(memmove)
> Perhaps this should be changed.  If nothing else, the ENTRY_NP should come
> first.

It is useful to have a copy that will be don in a 'generally forward'
direction regardless of the addresses.

There is also a bug in the first 2 instructions!

        /* Determine copy direction */
        cmp     r1, r0

        moveq   r0, #0                  /* Quick abort for len=0 */
#ifdef __APCS_26__
        moveqs  pc, lr 
        moveq   pc, lr  

Surely the 'moveq r0,#0' should be 'cmpne r2,#0' ?
At the moment the return value of memcpy(x,x,n) is 0 instead of x.

I almost wonder if the 'zero length' optimisation is worth
the 2 instructions in the 'normal' path.
Certainly the src == dest optimisation is doubtful?


David Laight: