[libcxx] r281310 - [libcxx] Fix gcc builds.

Asiri Rathnayake via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 13 02:32:32 PDT 2016


Author: asiri
Date: Tue Sep 13 04:32:32 2016
New Revision: 281310

URL: http://llvm.org/viewvc/llvm-project?rev=281310&view=rev
Log:
[libcxx] Fix gcc builds.

Step around a gcc pre-processor defect which causes it to fail to
parse the __has_include macro check.

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=281310&r1=281309&r2=281310&view=diff
==============================================================================
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Tue Sep 13 04:32:32 2016
@@ -19,9 +19,20 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && (!defined(__has_include) || __has_include(<__external_threading>))
+// 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>
-#else
+#define _LIBCPP_EXTERNAL_THREADING
+#elif !defined(__has_include) || __has_include(<__external_threading>)
+#include <__external_threading>
+#define _LIBCPP_EXTERNAL_THREADING
+#endif
+#endif
+
+#if !defined(_LIBCPP_EXTERNAL_THREADING)
 #include <pthread.h>
 #include <sched.h>
 #endif




More information about the cfe-commits mailing list