Natural alignment for USE_MALLOC (#248)

* Add concept of natural alignment to tests.

snmalloc naturally aligns blocks very heavily, so that
the largest power-of-two in the rounded size is the alignment.
This checks that in the test, and provides a method for
finding the natural alignment of a block.

* Improve USE_MALLOC to provide alignment

snmalloc provides a lot of alginment guarantees. This ensures that when
we pass through to the system allocator we still get those alignment
guarantees.

The commit also fixes the tests to work with USE_MALLOC, and builds a
set of unit tests for ctest to check behaviour.
This commit is contained in:
Matthew Parkinson
2020-09-28 10:08:19 +01:00
committed by GitHub
parent f89f78ad46
commit 923705e514
16 changed files with 203 additions and 54 deletions

View File

@@ -85,16 +85,18 @@ namespace test
int main(int, char**)
{
#ifndef SNMALLOC_PASS_THROUGH // Depends on snmalloc specific features
setup();
xoroshiro::p128r64 r;
#ifdef NDEBUG
# ifdef NDEBUG
size_t nn = 30;
#else
# else
size_t nn = 3;
#endif
# endif
for (size_t n = 0; n < nn; n++)
test::test_external_pointer(r);
return 0;
#endif
}