This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Replace __sync_* functions with __libcpp_atomic_* functions
ClosedPublic

Authored by weimingz on Jul 10 2017, 6:32 PM.

Details

Summary

include/atomic_support.h already handles case for _LIBCPP_HAS_NO_THREADS.
This patch reverts r307595, changes sync_* to libcpp_atomic_*, and adds a wrapper function for __atomic_exchange.

Diff Detail

Event Timeline

weimingz created this revision.Jul 10 2017, 6:32 PM
weimingz updated this revision to Diff 106998.Jul 17 2017, 6:10 PM

rebased after reverting r307595 and moving __refstring header

weimingz updated this revision to Diff 110041.Aug 7 2017, 11:51 AM

rebased. Please review. Thanks

efriedma edited reviewers, added: mclow.lists; removed: eli.friedman.Aug 30 2017, 3:00 PM
efriedma added subscribers: joerg, cfe-commits.
compnerd accepted this revision.Sep 12 2017, 5:58 PM
compnerd added a subscriber: compnerd.

Why the additional inclusion of the support in the files which are not modified to use functions? (e.g. src/stdexcept.cpp). LG otherwise.

src/include/atomic_support.h
160

Really annoying that you can't immediately tell that this is in the _LIBCPP_NO_THREADS case, and thus the atomicity is not required.

This revision is now accepted and ready to land.Sep 12 2017, 5:58 PM
weimingz updated this revision to Diff 115891.Sep 19 2017, 1:36 PM

Moved the inclusion from stdexcept.cpp into refstring.h

For exception.cpp and new.cpp, I think it's better to keep the inclusion there. Those files include new_handler_fallback.ipp, exception_fallback.ipp, which need the header file. Including it in those .ipp requires relative path as "../../include/atomic_support.h" and I tried to avoid that.

EricWF accepted this revision.Sep 19 2017, 2:53 PM
EricWF added inline comments.
src/include/atomic_support.h
153

Initialize old on the same line it's declared on.

weimingz updated this revision to Diff 115918.Sep 19 2017, 4:09 PM

minor change

This revision was automatically updated to reflect the committed changes.