[libcxx] r268850 - Fix memory_resource build for _LIBCPP_HAS_NO_THREADS

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri May 6 22:37:31 PDT 2016


Author: ericwf
Date: Sat May  7 00:37:31 2016
New Revision: 268850

URL: http://llvm.org/viewvc/llvm-project?rev=268850&view=rev
Log:
Fix memory_resource build for _LIBCPP_HAS_NO_THREADS

Modified:
    libcxx/trunk/src/experimental/memory_resource.cpp

Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=268850&r1=268849&r2=268850&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Sat May  7 00:37:31 2016
@@ -11,7 +11,7 @@
 
 #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
 #include "atomic"
-#else
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
 #include "mutex"
 #endif
 
@@ -100,7 +100,7 @@ __default_memory_resource(bool set = fal
         return _VSTD::atomic_load_explicit(
             &__res, memory_order::memory_order_acquire);
     }
-#else
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
     static memory_resource * res = &res_init.resources.new_delete_res;
     static mutex res_lock;
     if (set) {
@@ -113,6 +113,16 @@ __default_memory_resource(bool set = fal
         lock_guard<mutex> guard(res_lock);
         return res;
     }
+#else
+    static memory_resource* res = &res_init.resources.new_delete_res;
+    if (set) {
+        new_res = new_res ? new_res : new_delete_resource();
+        memory_resource * old_res = res;
+        res = new_res;
+        return old_res;
+    } else {
+        return res;
+    }
 #endif
 }
 




More information about the cfe-commits mailing list