[libcxx-commits] [PATCH] D66480: Fix unavailability of __thread_id on external builds

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 20 08:24:34 PDT 2019


mclow.lists created this revision.
mclow.lists added reviewers: EricWF, ldionne.
Herald added subscribers: jfb, dexonsmith, christof.
Herald added a project: libc++.

In fixing https://bugs.llvm.org/show_bug.cgi?id=42918 (r368916), I broke external threading support.
This should fix that

I don't have an external threading setup, so I'd appreciate it if someone who had one could test this.
I have tested with pthreads and with no-threads.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66480

Files:
  libcxx/include/__threading_support


Index: libcxx/include/__threading_support
===================================================================
--- libcxx/include/__threading_support
+++ libcxx/include/__threading_support
@@ -23,16 +23,11 @@
 # include <__external_threading>
 #elif !defined(_LIBCPP_HAS_NO_THREADS)
 
-typedef ::timespec __libcpp_timespec_t;
-
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include <pthread.h>
 # include <sched.h>
 #endif
 
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
     defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \
     defined(_LIBCPP_HAS_THREAD_API_WIN32)
@@ -47,8 +42,16 @@
 #define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 #endif
 
+typedef ::timespec __libcpp_timespec_t;
+#endif // !defined(_LIBCPP_HAS_NO_THREADS)
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
 typedef pthread_mutex_t __libcpp_mutex_t;
@@ -109,7 +112,7 @@
 typedef long __libcpp_tls_key;
 
 #define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
-#endif
+#endif // defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 // Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -475,10 +478,10 @@
 
 }  // this_thread
 
+#endif // !_LIBCPP_HAS_NO_THREADS
+
 _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS
 
-#endif // !_LIBCPP_HAS_NO_THREADS
-
 #endif // _LIBCPP_THREADING_SUPPORT


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66480.216154.patch
Type: text/x-patch
Size: 1420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190820/dea1495c/attachment.bin>


More information about the libcxx-commits mailing list