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>
Thu, 24 Feb 2022 17:56:45 +0000 (09:56 -0800)
commit4d7ebd54b584ed7adee8c882d2c7f9635b8fba2f
tree72ddf3d5595d1ace8a4dd8bf05073e83be9708fd
parent0eccbeabf5fc5f5b184ffa97074e4676f1083331
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