// <experimental/memory_resource> -*- C++ -*-
-// Copyright (C) 2015-2022 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
#include <bits/new_allocator.h>
#include <debug/assertions.h>
-/// @cond
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp> class malloc_allocator;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __gnu_cxx
-/// @endcond
namespace std {
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// 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;