I didn't see the difference of above 2 ranches. Did I miss something?
Also why not directly use memcpy?
[Cao, Minggui] I improve it here for that: it could use to move / copy chars in the same buffer (could be partly overlap) and it could start from
right or left.
I have checked the HV's memcpy can't fill this requirement.
1: This is not char copy, but memory copy. 2: The reason memcpy today doesn’t support this feature is because it only work with DF=0 (REP MOVSB). We can easily extend to support DF=1.
[Cao, Minggui] sorry, I mixed the copy and move; it shall be like memmove. Just checked the memory.c code in HV.
Is it OK as follows? memcpy_erms --> memmove_erms (void *d, const void *s, size_t slen, bool df_flag) as a public API?
The caller side clearly know the copy to be from head to tail address or from tail to head address. How about to define another API like memcpy_tail_to_head or memcpy_rev ?
The caller side can choose normal memcpy or tail_to_head copy API.