This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add strxfrm Implementation
ClosedPublic

Authored by Caslyn on Apr 3 2023, 3:27 PM.

Details

Summary

Introduce strxfrm and unit tests. The current implementation is
introduced without locale support.

The simplified function performs a memcpy if the n value is large
enough to store the source len + '\0', otherwise dest is unmodified.

Ticket: https://fxbug.dev/124217

Diff Detail

Event Timeline

Caslyn created this revision.Apr 3 2023, 3:27 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 3 2023, 3:27 PM
Caslyn requested review of this revision.Apr 3 2023, 3:27 PM
Caslyn updated this revision to Diff 510625.Apr 3 2023, 3:37 PM

Amended commit message

Caslyn edited the summary of this revision. (Show Details)Apr 3 2023, 3:38 PM
Caslyn updated this revision to Diff 510644.Apr 3 2023, 4:45 PM

Fix typo, unneeded import

michaelrj accepted this revision.Apr 5 2023, 10:08 AM

LGTM after fixing one issue.

libc/src/string/strxfrm.cpp
19

The pointer arguments for strxfrm need to be tagged with __restrict both here and in the header.

This revision is now accepted and ready to land.Apr 5 2023, 10:08 AM
Caslyn updated this revision to Diff 511555.Apr 6 2023, 4:16 PM

Add __restrict to pointer args

Caslyn marked an inline comment as done.Apr 6 2023, 4:17 PM
This revision was automatically updated to reflect the committed changes.