string: Improve generic stpcpy
commit30c1dfde313fa01e195e0759915f1356effdb7d6
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 31 Jan 2023 18:46:08 +0000 (31 15:46 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 6 Feb 2023 19:19:35 +0000 (6 16:19 -0300)
tree7a94f097603e6f23d86bc644ab1df577b3006cb6
parent367c31b5d61164db97834917f5487094ebef2f58
string: Improve generic stpcpy

It follows the strategy:

  - Align the destination on word boundary using byte operations.

  - If source is also word aligned, read a word per time, check for
    null (using has_zero from string-fzb.h), and write the remaining
    bytes.

  - If source is not word aligned, loop by aligning the source, and
    merging the result of two reads.  Similar to aligned case,
    check for null with has_zero, and write the remaining bytes if
    null is found.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
string/stpcpy.c