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, 21 Apr 2022 00:05:44 +0000 (17:05 -0700)
commitd8dcc2d8d93e5d4263ca9f8c5bdfb713f82fe923
tree6c1aefa5cf149f006e4f2f07dd904222915750e2
parent830acd088edc1604ee46916188491ef634441fc6
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