]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
amd64: reimplement libc memcmp and bcmp with kernel memcmp
authormjg <mjg@FreeBSD.org>
Thu, 27 Sep 2018 17:08:29 +0000 (17:08 +0000)
committermjg <mjg@FreeBSD.org>
Thu, 27 Sep 2018 17:08:29 +0000 (17:08 +0000)
commit09cca5134de06f43a71cc22120ee9aa1aaaeb472
tree3424ceefebf5d03d51ac7404809f4d1558942b0e
parentb091ea3772c2bb4eb0ba47d5ae006dc021342ccc
amd64: reimplement libc memcmp and bcmp with kernel memcmp

Both are significantly slower than hand-coded loops. See r338963 for
kernel commit.

bcmp differs from memcmp by always returning 1 when a difference is
found, as opposed to going for a value bigger or lower than 0
depending on what it is. This means it can do less work. For now the
code is duplicated and modified. This will get deduplicated after
another round of optimization when memcmp will get a longer-term form.

Both tested with the glibc suite. While the suite does not have a test
for bcmp, I created a wrapper routine which verified that values match
(0 vs 0, 1 vs non-zero).

Reviewed by: kib
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17336
lib/libc/amd64/string/bcmp.S
lib/libc/amd64/string/memcmp.S