[PATCH v3 1/3] riscv: optimized memcpy

Nick Kossifidis mick at ics.forth.gr
Wed Jun 23 02:48:30 PDT 2021


Στις 2021-06-23 02:35, Matteo Croce έγραψε:
>> 
>> If you want to be compliant with memcpy you should check for 
>> overlapping
>> regions here since "The memory areas must not overlap", and do nothing
>> about it because according to POSIX this leads to undefined behavior.
>> That's why recent libc implementations use memmove in any case (memcpy
>> is an alias to memmove), which is the suggested approach.
>> 
> 
> Mmm which memcpy arch implementation does this check?
> I guess that noone is currently doing it.
> 

Yup because even if they did the wouldn't know what to do about it since 
POSIX leaves this as undefined behavior. So instead of using memcpy it's 
suggested that people use memmove that can handle overlapping regions, 
and because we can't patch the rest of the kernel to only use memmove 
(or the rest of the programs if we were a libc), the idea is to just 
alias memcpy to memmove (BTW Torvalds also thinks this is a good idea: 
https://bugzilla.redhat.com/show_bug.cgi?id=638477#c132).



More information about the linux-riscv mailing list