[U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address

Albert ARIBAUD albert.u.boot at aribaud.net
Mon May 23 11:49:10 CEST 2011


Le 23/05/2011 11:30, Alexander Holler a écrit :
> Am 23.05.2011 11:06, schrieb Matthias Weisser:
>> In some cases (e.g. bootm with a elf payload which is already at the right
>> position) there is a in place copy of data to the same address. Catching this
>> saves some ms while booting.
>>
>> Signed-off-by: Matthias Weisser<weisserm at arcor.de>
>> ---
>>    arch/arm/lib/memcpy.S |    3 +++
>>    1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
>> index 3b5aeec..f655256 100644
>> --- a/arch/arm/lib/memcpy.S
>> +++ b/arch/arm/lib/memcpy.S
>> @@ -60,6 +60,9 @@
>>    .globl memcpy
>>    memcpy:
>>
>> +		cmp	r0, r1
>> +		moveq	pc, lr
>> +
>>    		enter	r4, lr
>>
>>    		subs	r2, r2, #4
>
> The standard clearly say to both memory regions should not overlap when
> memcpy() is used, so I would say this is the wrong place to fix that.

I think the intent here is not to enforce the standard but to handle an 
actual, and degenerate, copy request in the most efficient manner, and 
in that respect, the patch does its job.

Besides, if the patch was about enforcing the standard, then I would 
consider it highly more efficient to check the areas once in the memcpy 
function than duplicating this check before each call to the function, 
considering that the place where the copy happens is not necessarily the 
one where the source and destination were computed.

> Regards,
>
> Alexander

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list