8000 fix GCC Bug 57350: std::align missing by templateU · Pull Request #453 · boostorg/asio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix GCC Bug 57350: std::align missing #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
0