add make_align for size alignment

This commit is contained in:
木头云 2021-05-07 15:41:32 +08:00 committed by GitHub
parent a4a7b85f47
commit d6ab58fc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,4 +53,9 @@ T horrible_cast(U val) {
return u.out; return u.out;
} }
IPC_CONSTEXPR_ std::size_t make_align(std::size_t align, std::size_t size) {
// align must be 2^n
return (size + align - 1) & ~(align - 1);
}
} // namespace ipc } // namespace ipc