This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add [l|ll]abs implementation.
ClosedPublic

Authored by cheng.w on Dec 3 2020, 6:03 PM.

Details

Summary

Implement abs, labs and llabs with template.

Diff Detail

Event Timeline

cheng.w created this revision.Dec 3 2020, 6:03 PM
cheng.w requested review of this revision.Dec 3 2020, 6:03 PM
sivachandra accepted this revision.Dec 4 2020, 10:31 AM

Thanks for the patch. Feel free to do labs and llabs as well. You can drive all of them off of a C++ template implementation.

This revision is now accepted and ready to land.Dec 4 2020, 10:31 AM

Forgot to mention couple of nits.

libc/src/stdlib/abs.cpp
21

Fix.

libc/src/stdlib/abs.h
19

Fix.

Thanks for your guidance. memmove needs abs. ; )

cheng.w updated this revision to Diff 310442.Dec 9 2020, 12:59 AM
cheng.w retitled this revision from [libc] Add abs implementation. to [libc] Add [l|ll]abs implementation..

Implement abs, labs and llabs with template.

cheng.w requested review of this revision.Dec 9 2020, 1:01 AM
cheng.w marked 2 inline comments as done.
sivachandra accepted this revision.Dec 10 2020, 12:17 AM
sivachandra added inline comments.
libc/src/stdlib/abs_utils.h
15

Nit: May be give it a name integer_abs and avoid the _ prefix.

This revision is now accepted and ready to land.Dec 10 2020, 12:17 AM
cheng.w updated this revision to Diff 310788.Dec 10 2020, 1:16 AM
cheng.w edited the summary of this revision. (Show Details)

Fix nit.

cheng.w marked an inline comment as done.Dec 10 2020, 5:14 PM
This revision was automatically updated to reflect the committed changes.