30 #ifndef _GLIBCXX_ALIGN_H
31 #define _GLIBCXX_ALIGN_H 1
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
60 align(
size_t __align,
size_t __size,
void*& __ptr,
size_t& __space) noexcept
64 const auto __intptr =
reinterpret_cast<__UINTPTR_TYPE__
>(__ptr);
65 const auto __aligned = (__intptr - 1u + __align) & -__align;
66 const auto __diff = __aligned - __intptr;
67 if (__diff > (__space - __size))
72 return __ptr =
reinterpret_cast<void*
>(__aligned);
76 #ifdef __glibcxx_assume_aligned
87 template<
size_t _Align,
class _Tp>
88 [[nodiscard,__gnu__::__always_inline__]]
92 static_assert(std::has_single_bit(_Align));
93 if (std::is_constant_evaluated())
99 _GLIBCXX_DEBUG_ASSERT((__UINTPTR_TYPE__)__ptr % _Align == 0);
100 return static_cast<_Tp*
>(__builtin_assume_aligned(__ptr, _Align));
105 _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.