Page MenuHomePhabricator

[libc++][AIX] Fix abs and div overload issue for compilers on AIX
ClosedPublic

Authored by jasonliu on Thu, Apr 1, 1:36 PM.

Details

Summary

AIX system's stdlib.h provide different overload of abs and div depending on compiler versions.
For example, std::div(long, long) and std::abs(long) are not available from OS's stdlib.h when building with clang, but they are available when building with xlclang compiler.
Therefore, we need to provide those extra overloads in libc++'s stdlib.h when OS's stdlib.h does not.

Diff Detail

Event Timeline

jasonliu created this revision.Thu, Apr 1, 1:36 PM
jasonliu requested review of this revision.Thu, Apr 1, 1:36 PM
Quuxplusone added inline comments.
libcxx/include/stdlib.h
105โ€“115

I think this is the equivalent of what you have (just significantly disentangled, and making it more obvious that we don't know why __sun__ is in there ๐Ÿ˜›). What do you think?
I'd also want to see a similar disentangling performed for the floating-point abses.

jasonliu updated this revision to Diff 334845.Thu, Apr 1, 4:10 PM

Remove extra conditions because we only intended to target the headers for clang compilers.

jasonliu added inline comments.Thu, Apr 1, 4:17 PM
libcxx/include/stdlib.h
105โ€“115

Thanks Author.
I think we could actually remove the extra conditions on AIX because we are only going to compile this header with the clang compiler. And we don't really need to consider xlclang/xlc because those compilers do not have enough language features to compile the latest libc++ trunk anyway. (Those changes are originally from our downstream libc++ which is a fairly old version)
If you still want that disentangled version as a drive-by fix, let me know and I could do that.

ldionne accepted this revision.Thu, Apr 8, 1:28 PM

Please rebase onto main to re-trigger CI. This LGTM if CI passes.

This revision is now accepted and ready to land.Thu, Apr 8, 1:28 PM

Double checked re: scope of __ABS_LONG__. Confirming LGTM re: AIX context.

jasonliu updated this revision to Diff 336240.Thu, Apr 8, 3:00 PM

Update diff to trigger pre-CI rebuild.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. ยท View Herald TranscriptFri, Apr 9, 7:47 AM
Herald added a subscriber: libcxx-commits. ยท View Herald Transcript