1Description: Fix incompatibility between <stdatomic.h> and <atomic> 2 This 2 headers combined will cause errors for both GCC and Clang. This patch 3 makes sure only one of them is present at any time. 4Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 5Bug: https://reviews.llvm.org/D45470 6--- a/libcutils/include/cutils/trace.h 7+++ b/libcutils/include/cutils/trace.h 8@@ -18,7 +18,14 @@ 9 #define _LIBS_CUTILS_TRACE_H 10 11 #include <inttypes.h> 12+#ifdef __cplusplus 13+#include <atomic> 14+using std::atomic_bool; 15+using std::atomic_load_explicit; 16+using std::memory_order_acquire; 17+#else 18 #include <stdatomic.h> 19+#endif 20 #include <stdbool.h> 21 #include <stdint.h> 22 #include <stdio.h> 23--- a/libcutils/include/cutils/atomic.h 24+++ b/libcutils/include/cutils/atomic.h 25@@ -19,7 +19,23 @@ 26 27 #include <stdint.h> 28 #include <sys/types.h> 29+#ifdef __cplusplus 30+#include <atomic> 31+using std::atomic_compare_exchange_strong_explicit; 32+using std::atomic_fetch_add_explicit; 33+using std::atomic_fetch_or_explicit; 34+using std::atomic_fetch_sub_explicit; 35+using std::atomic_int_least32_t; 36+using std::atomic_load_explicit; 37+using std::atomic_store_explicit; 38+using std::atomic_thread_fence; 39+using std::memory_order::memory_order_acquire; 40+using std::memory_order::memory_order_relaxed; 41+using std::memory_order::memory_order_release; 42+using std::memory_order::memory_order_seq_cst; 43+#else 44 #include <stdatomic.h> 45+#endif 46 47 #ifndef ANDROID_ATOMIC_INLINE 48 #define ANDROID_ATOMIC_INLINE static inline 49--- a/liblog/logger.h 50+++ b/liblog/logger.h 51@@ -16,7 +16,13 @@ 52 53 #pragma once 54 55+#ifdef __cplusplus 56+#include <atomic> 57+using std::atomic_int; 58+using std::atomic_uintptr_t; 59+#else 60 #include <stdatomic.h> 61+#endif 62 #include <stdbool.h> 63 64 #include <cutils/list.h> 65--- a/liblog/logger_write.cpp 66+++ b/liblog/logger_write.cpp 67@@ -15,7 +15,6 @@ 68 */ 69 70 #include <errno.h> 71-#include <stdatomic.h> 72 #include <stdlib.h> 73 #include <string.h> 74 #include <sys/time.h> 75