1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-05 22:10:24 +00:00

AK: Align Function storage to __BIGGEST_ALIGNMENT__ outside kernel

The previous alignment would always resolve to 8-bytes, which is below
the required alignments of types that could exist in userspace (long
double, 128-bit integers, SSE, etc).
This commit is contained in:
MacDue 2023-06-15 22:56:05 +01:00 committed by Jelle Raaijmakers
parent a433cbefbe
commit d4d92184b3

View File

@ -276,11 +276,13 @@ private:
#ifndef KERNEL
// Empirically determined to fit most lambdas and functions.
static constexpr size_t inline_capacity = 4 * sizeof(void*);
alignas(__BIGGEST_ALIGNMENT__) u8 m_storage[inline_capacity];
#else
// FIXME: Try to decrease this.
static constexpr size_t inline_capacity = 6 * sizeof(void*);
// In the Kernel nothing has an alignment > alignof(void*).
alignas(alignof(void*)) u8 m_storage[inline_capacity];
#endif
alignas(max(alignof(CallableWrapperBase), alignof(CallableWrapperBase*))) u8 m_storage[inline_capacity];
};
}