Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/boost/asio/detail/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,23 @@ inline const volatile T* to_address(const volatile T* p) { return p; }
inline void* align(std::size_t alignment,
std::size_t size, void*& ptr, std::size_t& space)
{
#if defined(__GNUC__) && __GNUC__ < 5
// copy from g++11.4.0
if (space < size)
return nullptr;
const auto __intptr = reinterpret_cast<uintptr_t>(ptr);
const auto __aligned = (__intptr - 1u + alignment) & -alignment;
const auto __diff = __aligned - __intptr;
if (__diff > (space - size))
return nullptr;
else
{
space -= __diff;
return ptr = reinterpret_cast<void *>(__aligned);
}
#else
return std::align(alignment, size, ptr, space);
#endif
}

} // namespace detail
Expand Down