Page MenuHomeFreeBSD

amd64: make bcmp in libc just call memcmp
ClosedPublic

Authored by mjg on Feb 21 2021, 9:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 17, 9:50 PM
Unknown Object (File)
Fri, Jan 10, 6:18 AM
Unknown Object (File)
Dec 22 2024, 1:06 AM
Unknown Object (File)
Dec 16 2024, 9:54 PM
Unknown Object (File)
Dec 13 2024, 1:04 AM
Unknown Object (File)
Dec 9 2024, 6:06 PM
Unknown Object (File)
Nov 26 2024, 11:23 AM
Unknown Object (File)
Nov 25 2024, 2:49 PM
Subscribers

Details

Summary

Preferably bcmp would just alias memcmp but there is magic which makes
this problematic.

A note should be made that bcmp which finds a difference has less work
to do but it's not worth implementing it just for this case.

This has a side effect of syncing assembly missed on memcmp rewrite.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mjg requested review of this revision.Feb 21 2021, 9:48 PM
mjg created this revision.
mjg edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Feb 25 2021, 7:19 PM
lib/libc/amd64/string/bcmp.c
3

The comment should be updated, same as for strlen().

This revision was automatically updated to reflect the committed changes.

FYI as of LLVM 9, clang will optimize memcmp calls that only check for equality to bcmp.

The optimizer will now convert calls to memcmp into a calls to bcmp in some circumstances. Users who are building freestanding code (not depending on the platform’s libc) without specifying -ffreestanding may need to either pass -fno-builtin-bcmp, or provide a bcmp function.

Huh, that changes things. In this case I may end up implementing a dedicated bcmp for both the kernel and libc.