[libunwind] Add support for a single-threaded libunwind build
The EHABI unwinder is thread-agnostic, SJLJ unwinder and the DWARF unwinder have
a couple of pthread dependencies.
This patch makes it possible to build the whole of libunwind for a
single-threaded environment.
Reviewers: compnerd
Differential revision: https://reviews.llvm.org/D24984
llvm-svn: 282575
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 6264758cc8cd62205b9073828359fb866bc27d59
diff --git a/src/Unwind_AppleExtras.cpp b/src/Unwind_AppleExtras.cpp
index b8baef5..d8301c0 100644
--- a/src/Unwind_AppleExtras.cpp
+++ b/src/Unwind_AppleExtras.cpp
@@ -185,21 +185,29 @@
#if !defined(FOR_DYLD) && _LIBUNWIND_BUILD_SJLJ_APIS
-#include <System/pthread_machdep.h>
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+ #include <System/pthread_machdep.h>
+#else
+ _Unwind_FunctionContext *fc_ = nullptr;
+#endif
// Accessors to get get/set linked list of frames for sjlj based execeptions.
_LIBUNWIND_HIDDEN
struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
return (struct _Unwind_FunctionContext *)
_pthread_getspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key);
+#else
+ return fc_;
+#endif
}
_LIBUNWIND_HIDDEN
void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
_pthread_setspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key, fc);
+#else
+ fc_ = fc;
+#endif
}
#endif
-
-
-
-