memory 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // <memory> -*- C++ -*-
  2. // Copyright (C) 2001-2023 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /*
  21. * Copyright (c) 1997-1999
  22. * Silicon Graphics Computer Systems, Inc.
  23. *
  24. * Permission to use, copy, modify, distribute and sell this software
  25. * and its documentation for any purpose is hereby granted without fee,
  26. * provided that the above copyright notice appear in all copies and
  27. * that both that copyright notice and this permission notice appear
  28. * in supporting documentation. Silicon Graphics makes no
  29. * representations about the suitability of this software for any
  30. * purpose. It is provided "as is" without express or implied warranty.
  31. *
  32. */
  33. /** @file include/memory
  34. * This is a Standard C++ Library header.
  35. * @ingroup memory
  36. */
  37. #ifndef _GLIBCXX_MEMORY
  38. #define _GLIBCXX_MEMORY 1
  39. #pragma GCC system_header
  40. /**
  41. * @defgroup memory Memory
  42. * @ingroup utilities
  43. *
  44. * Components for memory allocation, deallocation, and management.
  45. */
  46. /**
  47. * @defgroup pointer_abstractions Pointer Abstractions
  48. * @ingroup memory
  49. *
  50. * Smart pointers, etc.
  51. */
  52. #include <bits/memoryfwd.h>
  53. #if _GLIBCXX_HOSTED
  54. # include <bits/allocator.h>
  55. # include <bits/stl_tempbuf.h>
  56. #endif
  57. #include <bits/stl_construct.h>
  58. #include <bits/stl_uninitialized.h>
  59. #include <bits/stl_raw_storage_iter.h>
  60. #if __cplusplus >= 201103L
  61. # include <type_traits>
  62. # include <bits/align.h>
  63. # include <bits/uses_allocator.h>
  64. # include <bits/alloc_traits.h>
  65. # include <debug/debug.h>
  66. # include <bits/unique_ptr.h>
  67. # if _GLIBCXX_HOSTED
  68. # include <bits/shared_ptr.h>
  69. # include <bits/shared_ptr_atomic.h>
  70. # endif
  71. #endif
  72. #if __cplusplus < 201103L || _GLIBCXX_USE_DEPRECATED
  73. # include <backward/auto_ptr.h>
  74. #endif
  75. #if __cplusplus > 201703L
  76. # include <bits/ranges_uninitialized.h>
  77. # include <bits/uses_allocator_args.h>
  78. #endif
  79. /* As a hack, we declare __cpp_lib_atomic_value_initialization here even though
  80. we don't include the bit that actually declares it, for consistency. */
  81. #if !defined(__cpp_lib_atomic_value_initialization) && __cplusplus >= 202002L
  82. # define __cpp_lib_atomic_value_initialization 201911L
  83. #endif
  84. #if __cplusplus >= 201103L && __cplusplus <= 202002L && _GLIBCXX_HOSTED
  85. namespace std _GLIBCXX_VISIBILITY(default)
  86. {
  87. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  88. /** @defgroup ptr_safety Pointer Safety and Garbage Collection
  89. * @ingroup memory
  90. *
  91. * Utilities to assist with garbage collection in an implementation
  92. * that supports <em>strict pointer safety</em>.
  93. * This implementation only supports <em>relaxed pointer safety</em>
  94. * and so these functions have no effect.
  95. *
  96. * C++11 20.6.4 [util.dynamic.safety], Pointer safety
  97. *
  98. * @{
  99. */
  100. /// Constants representing the different types of pointer safety.
  101. enum class pointer_safety { relaxed, preferred, strict };
  102. /// Inform a garbage collector that an object is still in use.
  103. inline void
  104. declare_reachable(void*) { }
  105. /// Unregister an object previously registered with declare_reachable.
  106. template <typename _Tp>
  107. inline _Tp*
  108. undeclare_reachable(_Tp* __p) { return __p; }
  109. /// Inform a garbage collector that a region of memory need not be traced.
  110. inline void
  111. declare_no_pointers(char*, size_t) { }
  112. /// Unregister a range previously registered with declare_no_pointers.
  113. inline void
  114. undeclare_no_pointers(char*, size_t) { }
  115. /// The type of pointer safety supported by the implementation.
  116. inline pointer_safety
  117. get_pointer_safety() noexcept { return pointer_safety::relaxed; }
  118. /// @}
  119. _GLIBCXX_END_NAMESPACE_VERSION
  120. } // namespace
  121. #endif // C++11 to C++20
  122. #if __cplusplus >= 201703L && _GLIBCXX_HOSTED
  123. // Parallel STL algorithms
  124. # if _PSTL_EXECUTION_POLICIES_DEFINED
  125. // If <execution> has already been included, pull in implementations
  126. # include <pstl/glue_memory_impl.h>
  127. # else
  128. // Otherwise just pull in forward declarations
  129. # include <pstl/glue_memory_defs.h>
  130. # endif
  131. // Feature test macro for parallel algorithms
  132. # define __cpp_lib_parallel_algorithm 201603L
  133. #endif // C++17
  134. #endif /* _GLIBCXX_MEMORY */