HomeFreeBSD

lib/libc/amd64/string: add memrchr() scalar, baseline implementation

Description

lib/libc/amd64/string: add memrchr() scalar, baseline implementation

The scalar implementation is fairly simplistic and only performs
slightly better than the generic C implementation. It could be
improved by using the same algorithm as for memchr, but it would
have been a lot more complicated.

The baseline implementation is similar to timingsafe_memcmp. It's
slightly slower than memchr() due to the more complicated main
loop, but I don't think that can be significantly improved.

Tested by: developers@, exp-run
Approved by: mjg
MFC after: 1 month
MFC to: stable/14
PR: 275785
Differential Revision: https://reviews.freebsd.org/D42925

(cherry picked from commit fb197a4f7751bb4e116989e57ba7fb12a981895f)

Details

Provenance
fuzAuthored on Dec 6 2023, 10:05 AM
Differential Revision
D42925: lib/libc/amd64/string: add memrchr scalar, baseline implementation
Parents
rGacb47064d658: lib/libc/tests/string: add memrchr unit tests
Branches
Unknown
Tags
Unknown