[libcxx] r284237 - [libcxx] Improve the gcc workaround for the missing __has_include macro.

Asiri Rathnayake via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 06:56:58 PDT 2016


Author: asiri
Date: Fri Oct 14 08:56:58 2016
New Revision: 284237

URL: http://llvm.org/viewvc/llvm-project?rev=284237&view=rev
Log:
[libcxx] Improve the gcc workaround for the missing __has_include macro.

NFC.

Modified:
    libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=284237&r1=284236&r2=284237&view=diff
==============================================================================
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri Oct 14 08:56:58 2016
@@ -19,20 +19,18 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-// These checks are carefully arranged so as not to trigger a gcc pre-processor
-// defect which causes it to fail to parse the __has_include check below, the
-// redundancy is intentional.
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#if !defined(__clang__) && (_GNUC_VER < 500)
-#include <__external_threading>
-#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
-#elif !defined(__has_include) || __has_include(<__external_threading>)
-#include <__external_threading>
-#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
-#endif
+#ifndef __libcpp_has_include
+  #ifndef __has_include
+    #define __libcpp_has_include(x) 0
+  #else
+    #define __libcpp_has_include(x) __has_include(x)
+  #endif
 #endif
 
-#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+    __libcpp_has_include(<__external_threading>)
+#include <__external_threading>
+#else
 #include <pthread.h>
 #include <sched.h>
 
@@ -241,7 +239,7 @@ void __libcpp_tls_set(__libcpp_tls_key _
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+#endif // !_LIBCPP_HAS_THREAD_API_EXTERNAL || !__libcpp_has_include(<__external_threading>)
 
 #endif // _LIBCPP_HAS_NO_THREADS
 




More information about the cfe-commits mailing list