30#ifndef _GLIBCXX_ALIGN_H
31#define _GLIBCXX_ALIGN_H 1
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
61align(
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#ifdef __glibcxx_assume_aligned
88 template<
size_t _Align,
class _Tp>
89 [[nodiscard,__gnu__::__always_inline__]]
93 static_assert(std::has_single_bit(_Align));
94 if (std::is_constant_evaluated())
100 _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0);
101 return static_cast<_Tp*
>(__builtin_assume_aligned(__ptr, _Align));
106_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * assume_aligned(_Tp *__ptr) noexcept
Inform the compiler that a pointer is aligned.
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.