[PATCH v3 1/3] riscv: optimized memcpy
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
>> 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:
More information about the linux-riscv