]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/experimental/memory_resource
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / include / experimental / memory_resource
index 9f1cb42373eda34a1b1dd12c1828425315a4123d..bc2fdbf082ea005966f8d18d05f63cc5a58fca4b 100644 (file)
@@ -1,6 +1,6 @@
 // <experimental/memory_resource> -*- C++ -*-
 
-// Copyright (C) 2015-2023 Free Software Foundation, Inc.
+// Copyright (C) 2015-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -549,10 +549,20 @@ namespace pmr {
   // The default memory resource
 
   /// @cond undocumented
-  inline std::atomic<memory_resource*>&
+  inline auto&
   __get_default_resource()
   {
+#ifndef _GLIBCXX_HAS_GTHREADS
+    struct type {
+      using value_type = memory_resource*;
+      explicit type(value_type __r) : _M_r(__r) { }
+      value_type _M_r;
+      value_type load() const { return _M_r; }
+      value_type exchange(value_type __r) { return std::__exchange(_M_r, __r); }
+    };
+#else
     using type = atomic<memory_resource*>;
+#endif
     alignas(type) static unsigned char __buf[sizeof(type)];
     static type* __r = new(__buf) type(new_delete_resource());
     return *__r;