[PATCH] D56913: decoupling Freestanding atomic<T> from libatomic.a

Olivier Giroux via Phabricator reviews at reviews.llvm.org
Fri Jan 18 07:59:31 PST 2019


__simt__ created this revision.
Herald added a reviewer: jfb.
Herald added subscribers: libcxx-commits, miyuki, jfb, ldionne, christof.
Herald added a reviewer: jfb.

Hello,

I volunteered to write a first patch to make use of a Freestanding configuration in libcxx. The goal of this patch is to decouple non-lock-free atomic<T> from platform libraries, like libatomic.a, when a Freestanding implementation is selected. This plays a big role in the accelerator-integrated library that we are working on.

This patch is based on the GitHub monorepo as of today.

Copy/pasting how this works from my email thread to -dev:

1. Creates a single __cxx_atomic_* layer which is an adaptation of either __c11_atomic_*, preferentially, or else __atomic_*. (For __atomic_*, it’s a rename of the layer that’s there now. For __c11_atomic_*, it’s a new but boring wrapper that just forwards calls.)

2. Creates a __cxx_atomic_type<> template that is an alias to what should wrap the _Tp inside of an atomic<T> / atomic_flag. Defaults to the same _Atomic(_Tp) as today, either from C11 or from the adaptation layer.

3. Under #ifdef LIBCXX_FREESTANDING, introduce __cxx_locked_atomic_type<> with an implementation of __cxx_atomic_*, and redirect __cxx_atomic_type<> based on always-lock-freedom. a. In C++17 mode, it uses __atomic_is_always_lock_free. b. Otherwise, it uses the C lock-free macros as shown in wg21.link/p0152.

Thanks for looking this over,

Olivier


Repository:
  rCXX libc++

https://reviews.llvm.org/D56913

Files:
  libcxx/include/atomic

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56913.182520.patch
Type: text/x-patch
Size: 38466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190118/72cbd9b4/attachment-0001.bin>


More information about the libcxx-commits mailing list