Rewrite cxa guard implementation.

Authored by EricWF on Apr 23 2019, 6:47 PM.


Rewrite cxa guard implementation.

This patch does three main things:

(1) It re-writes the cxa guard implementation to make it testable.
(2) Adds support for recursive init detection on non-apple platforms.
(3) It adds a futex based implementation.

The futex based implementation locks and notifies on a per-object basis, unlike the
current implementation which uses a global lock for all objects. Once this patch settles
I'll turn it on by default when supported.

llvm-svn: 359060


EricWFApr 23 2019, 6:47 PM
rG0b098754b73f: Fix interactions between __builtin_constant_p and constexpr to match current…

Event Timeline

@EricWF is there an implicit expectation that all implementations based off libcxx/libcxxabi supports POSIX?
Our downstream ARM toolchain does not supply a unistd.h as part of its custom libc, and it has not been a problem until this revision.

Can you detail exactly which parts of unistd.h you're using here?

If I remove the header entirely, we get a number of build errors not related to undefined members from unistd.h. Specifically, LibcppMutex and LibcppCondVar are incomplete due to the only definitions being guarded by #ifndef _LIBCXXABI_HAS_NO_THREADS, which our implementation has set.

miyuki added a subscriber: miyuki.Apr 25 2019, 2:33 AM