forked from mirrors/gecko-dev
Bug 1325771 - mfbt:tests: Handle targets with less strict alignment in TestCompactPair r=jesup
Previously, the tests assumed that the alignment of int and long equals their size. This commit fixes the tests for targets like m68k that have sizeof(int) == 4 and alignof(int) == 2. A static helper function sizemax was introduced as the offset of the second element in Pair<int,long> might be either determined by its alignment requirement or the size of the preceding int element and we use the helper function to pick the larger of the two values. Depends on D77288 Differential Revision: https://phabricator.services.mozilla.com/D77289
This commit is contained in:
parent
ea002ac55c
commit
5e52229a75
1 changed files with 7 additions and 2 deletions
|
|
@ -35,8 +35,13 @@ using mozilla::MakeCompactPair;
|
|||
static_assert(sizeof(name##_2) == (size), \
|
||||
"CompactPair<" #T2 ", " #T1 "> has an unexpected size");
|
||||
|
||||
static constexpr size_t sizemax(size_t a, size_t b)
|
||||
{
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
INSTANTIATE(int, int, prim1, 2 * sizeof(int));
|
||||
INSTANTIATE(int, long, prim2, 2 * sizeof(long));
|
||||
INSTANTIATE(int, long, prim2, sizeof(long) + sizemax(sizeof(int), alignof(long)));
|
||||
|
||||
struct EmptyClass {
|
||||
explicit EmptyClass(int) {}
|
||||
|
|
@ -47,7 +52,7 @@ struct NonEmpty {
|
|||
};
|
||||
|
||||
INSTANTIATE(int, EmptyClass, both1, sizeof(int));
|
||||
INSTANTIATE(int, NonEmpty, both2, 2 * sizeof(int));
|
||||
INSTANTIATE(int, NonEmpty, both2, sizeof(int) + alignof(int));
|
||||
INSTANTIATE(EmptyClass, NonEmpty, both3, 1);
|
||||
|
||||
struct A {
|
||||
|
|
|
|||
Loading…
Reference in a new issue