tools/nolibc/string: use unidirectional variants for memcpy()
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Feb 2022 16:23:40 +0000 (17:23 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 14 Feb 2022 18:48:54 +0000 (10:48 -0800)
commita824078c6a8b051513b76bbf7c4f756ea1093106
treec19902a0c8d3fb3ebcb1c29cf1f469982e407111
parent47b0880daba01a8d775be1ac75b61fdbbce71105
tools/nolibc/string: use unidirectional variants for memcpy()

Till now memcpy() relies on memmove(), but it's always included for libgcc,
so we have a larger than needed function. Let's implement two unidirectional
variants to copy from bottom to top and from top to bottom, and use the
former for memcpy(). The variants are optimized to be compact, and at the
same time the compiler is sometimes able to detect the loop and to replace
it with a "rep movsb". The new function is 24 bytes instead of 52 on x86_64.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/include/nolibc/string.h