[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

git-svn-id: https://llvm.org/svn/llvm-project/libunwind/trunk@282575 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/config.h b/src/config.h
index 354e114..8743f53 100644
--- a/src/config.h
+++ b/src/config.h
@@ -85,13 +85,20 @@
   } while (0)
 #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
 
+#if defined(_LIBUNWIND_HAS_NO_THREADS)
+  // only used with pthread calls, not needed for the single-threaded builds
+  #define _LIBUNWIND_LOG_NON_ZERO(x)
+#endif
+
 // Macros that define away in non-Debug builds
 #ifdef NDEBUG
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)
   #define _LIBUNWIND_TRACE_API(msg, ...)
   #define _LIBUNWIND_TRACING_UNWINDING 0
   #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+    #define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #endif
 #else
   #ifdef __cplusplus
     extern "C" {
@@ -102,12 +109,14 @@
     }
   #endif
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)  _LIBUNWIND_LOG(msg, __VA_ARGS__)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) \
-            do { \
-              int _err = x; \
-              if ( _err != 0 ) \
-                _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
-             } while (0)
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+    #define _LIBUNWIND_LOG_NON_ZERO(x) \
+              do { \
+                int _err = x; \
+                if ( _err != 0 ) \
+                  _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
+               } while (0)
+  #endif
   #define _LIBUNWIND_TRACE_API(msg, ...) \
             do { \
               if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \