30 #ifndef _GLIBCXX_ALIGN_H
31 #define _GLIBCXX_ALIGN_H 1
38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
61 align(
size_t __align,
size_t __size,
void*& __ptr,
size_t& __space) noexcept
65 const auto __intptr =
reinterpret_cast<uintptr_t
>(__ptr);
66 const auto __aligned = (__intptr - 1u + __align) & -__align;
67 const auto __diff = __aligned - __intptr;
68 if (__diff > (__space - __size))
73 return __ptr =
reinterpret_cast<void*
>(__aligned);
77 #if __cplusplus > 201703L
78 #define __cpp_lib_assume_aligned 201811L
89 template<
size_t _Align,
class _Tp>
90 [[nodiscard,__gnu__::__always_inline__]]
92 assume_aligned(_Tp* __ptr) noexcept
94 static_assert(std::has_single_bit(_Align));
95 if (std::is_constant_evaluated())
101 _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0);
102 return static_cast<_Tp*
>(__builtin_assume_aligned(__ptr, _Align));
107 _GLIBCXX_END_NAMESPACE_VERSION
void * align(size_t __align, size_t __size, void *&__ptr, size_t &__space) noexcept
Fit aligned storage in buffer.
ISO C++ entities toplevel namespace is std.