[PATCH] D54456: [libcxx] Allow use of <atomic> in baremetal systems when threading is disabled.

Ian Tessier via Phabricator reviews at reviews.llvm.org
Mon Nov 12 17:18:19 PST 2018


itessier created this revision.
Herald added subscribers: jfb, ldionne, mgorny.
Herald added a reviewer: EricWF.

This will allow embedded projects that provide their own threading library to use the <atomic> library.


Repository:
  rCXX libc++

https://reviews.llvm.org/D54456

Files:
  CMakeLists.txt
  include/atomic


Index: include/atomic
===================================================================
--- include/atomic
+++ include/atomic
@@ -550,7 +550,7 @@
 #pragma GCC system_header
 #endif
 
-#ifdef _LIBCPP_HAS_NO_THREADS
+#if defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_BAREMETAL)
 #error <atomic> is not supported on this single threaded system
 #endif
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -242,6 +242,7 @@
 option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
     "Build libc++ with an externalized threading library.
      This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF)
+option(LIBCXX_BAREMETAL "Build libc++ for baremetal targets." OFF)
 
 # Misc options ----------------------------------------------------------------
 # FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -708,6 +709,7 @@
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
+config_define_if(LIBCXX_BAREMETAL _LIBCPP_BAREMETAL)
 
 if (LIBCXX_ABI_DEFINES)
   set(abi_defines)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54456.173790.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181113/0569055c/attachment.bin>


More information about the libcxx-commits mailing list