Skip to content

Commit 2145054

Browse files
committed
[libc++] decoupling Freestanding atomic<T> from libatomic.a
This patch introduces non-lockfree atomics that do not require using an external libatomic. This work is done with the long-term goal of allowing the use of <atomic> in freestanding environments. Thanks to Olivier Giroux for the patch. Differential Revision: https://reviews.llvm.org/D56913 llvm-svn: 355318
1 parent 881e83d commit 2145054

File tree

2 files changed

+759
-240
lines changed

2 files changed

+759
-240
lines changed

libcxx/include/__config

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
# define _LIBCPP_ABI_VERSION 1
3939
#endif
4040

41+
#ifndef __STDC_HOSTED__
42+
# define _LIBCPP_FREESTANDING
43+
#endif
44+
4145
#ifndef _LIBCPP_STD_VER
4246
# if __cplusplus <= 201103L
4347
# define _LIBCPP_STD_VER 11
@@ -1220,9 +1224,18 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
12201224
# define _LIBCPP_HAS_GCC_ATOMIC_IMP
12211225
#endif
12221226

1223-
#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
1227+
#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1228+
!defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1229+
!defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
12241230
|| defined(_LIBCPP_HAS_NO_THREADS)
1225-
#define _LIBCPP_HAS_NO_ATOMIC_HEADER
1231+
# define _LIBCPP_HAS_NO_ATOMIC_HEADER
1232+
#else
1233+
# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1234+
# define _LIBCPP_ATOMIC_FLAG_TYPE bool
1235+
# endif
1236+
# ifdef _LIBCPP_FREESTANDING
1237+
# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1238+
# endif
12261239
#endif
12271240

12281241
#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK

0 commit comments

Comments
 (0)