Allow libc++ to be built on systems without POSIX threads

If you're crazy enough to want this sort of thing, then add
-D_LIBCPP_HAS_NO_THREADS to your CXXFLAGS and
--param=additiona_features=libcpp-has-no-threads to your lit commnad line.

http://reviews.llvm.org/D3969

llvm-svn: 217271
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: b3fcc67f8f13cd95d36ed29d0ae1308decb9e099
diff --git a/src/algorithm.cpp b/src/algorithm.cpp
index 6d5cf7c..e548856 100644
--- a/src/algorithm.cpp
+++ b/src/algorithm.cpp
@@ -47,12 +47,16 @@
 
 template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
 
+#ifndef _LIBCPP_HAS_NO_THREADS
 static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
+#endif
 unsigned __rs_default::__c_ = 0;
 
 __rs_default::__rs_default()
 {
+#ifndef _LIBCPP_HAS_NO_THREADS
     pthread_mutex_lock(&__rs_mut);
+#endif
     __c_ = 1;
 }
 
@@ -63,8 +67,12 @@
 
 __rs_default::~__rs_default()
 {
+#ifndef _LIBCPP_HAS_NO_THREADS
     if (--__c_ == 0)
         pthread_mutex_unlock(&__rs_mut);
+#else
+    --__c_;
+#endif
 }
 
 __rs_default::result_type