43 #ifndef _GLIBCXX_MEMORY 44 #define _GLIBCXX_MEMORY 1 46 #pragma GCC system_header 69 #if __cplusplus >= 201103L 77 # include <bits/uses_allocator.h> 81 # include <bits/shared_ptr.h> 83 # if _GLIBCXX_USE_DEPRECATED 90 #if __cplusplus >= 201103L 92 #if __cplusplus > 201703L 95 namespace std _GLIBCXX_VISIBILITY(default)
97 _GLIBCXX_BEGIN_NAMESPACE_VERSION
116 align(
size_t __align,
size_t __size,
void*& __ptr,
size_t& __space) noexcept
118 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 119 const auto __intptr =
reinterpret_cast<uintptr_t
>(__ptr);
122 static_assert(
sizeof(
size_t) >=
sizeof(
void*),
123 "std::size_t must be a suitable substitute for std::uintptr_t");
124 const auto __intptr =
reinterpret_cast<unsigned long long>(__ptr);
126 const auto __aligned = (__intptr - 1u + __align) & -__align;
127 const auto __diff = __aligned - __intptr;
128 if ((__size + __diff) > __space)
133 return __ptr =
reinterpret_cast<void*
>(__aligned);
139 enum class pointer_safety { relaxed, preferred, strict };
142 declare_reachable(
void*) { }
144 template <
typename _Tp>
146 undeclare_reachable(_Tp* __p) {
return __p; }
149 declare_no_pointers(
char*,
size_t) { }
152 undeclare_no_pointers(
char*,
size_t) { }
154 inline pointer_safety
155 get_pointer_safety() noexcept {
return pointer_safety::relaxed; }
157 #if __cplusplus > 201703L 159 template<
size_t _Align,
class _Tp>
160 [[nodiscard,__gnu__::__always_inline__]]
161 constexpr _Tp* assume_aligned(_Tp* __ptr)
163 static_assert(std::ispow2(_Align));
164 _GLIBCXX_DEBUG_ASSERT((std::uintptr_t)__ptr % _Align == 0);
165 return static_cast<_Tp*
>(__builtin_assume_aligned(__ptr, _Align));
169 _GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
void * align(size_t __align, size_t __size, void *&__ptr, size_t &__space) noexcept
Fit aligned storage in buffer.