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)
Feb 11 2024, 8:28 PM
Unknown Object (File)
Dec 21 2023, 1:18 PM
Unknown Object (File)
Dec 20 2023, 8:16 AM
Unknown Object (File)
Dec 12 2023, 7:34 AM
Unknown Object (File)
Oct 10 2023, 12:36 PM
Unknown Object (File)
Aug 14 2023, 3:53 PM
Unknown Object (File)
Aug 14 2023, 1:44 PM
Unknown Object (File)
Aug 14 2023, 3:04 AM
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.