[PATCH] D26376: Undef stdatomic.h macro definitions that are defining functions provided in libc++ <atomic>

Mehdi AMINI via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 7 16:23:03 PST 2016


mehdi_amini created this revision.
mehdi_amini added a reviewer: rsmith.
mehdi_amini added a subscriber: cfe-commits.

This solved compiling:

  #include <stdatomic.h>
  #include <atomic>


https://reviews.llvm.org/D26376

Files:
  libcxx/include/atomic


Index: libcxx/include/atomic
===================================================================
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -560,6 +560,63 @@
 # define __cpp_lib_atomic_is_always_lock_free 201603L
 #endif
 
+// stdatomic.h may implement these as a macros, be safe and undef.
+#ifdef kill_dependency
+#undef kill_dependency
+#endif
+#ifdef atomic_is_lock_free
+#undef atomic_is_lock_free
+#endif
+#ifdef atomic_load
+#undef atomic_load
+#endif
+#ifdef atomic_exchange
+#undef atomic_exchange
+#endif
+#ifdef atomic_compare_exchange_weak
+#undef atomic_compare_exchange_weak
+#endif
+#ifdef atomic_compare_exchange_strong
+#undef atomic_compare_exchange_strong
+#endif
+#ifdef atomic_fetch_and
+#undef atomic_fetch_and
+#endif
+#ifdef atomic_fetch_add
+#undef atomic_fetch_add
+#endif
+#ifdef atomic_fetch_sub
+#undef atomic_fetch_sub
+#endif
+#ifdef atomic_store
+#undef atomic_store
+#endif
+#ifdef atomic_store_explicit
+#undef atomic_store_explicit
+#endif
+#ifdef atomic_flag_test_and_set
+#undef atomic_flag_test_and_set
+#endif
+#ifdef atomic_flag_test_and_set_explicit
+#undef atomic_flag_test_and_set_explicit
+#endif
+#ifdef atomic_exchange_explicit
+#undef atomic_exchange_explicit
+#endif
+#ifdef atomic_flag_clear
+#undef atomic_flag_clear
+#endif
+#ifdef atomic_fetch_xor
+#undef atomic_fetch_xor
+#endif
+#ifdef atomic_flag_clear_explicit
+#undef atomic_flag_clear_explicit
+#endif
+#ifdef atomic_fetch_or
+#undef atomic_fetch_or
+#endif
+
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 typedef enum memory_order


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26376.77116.patch
Type: text/x-patch
Size: 1541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161108/8f7bdaeb/attachment.bin>


More information about the cfe-commits mailing list