Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2020-01-23 16:17:13 +0300
committerJacques Lucke <mail@jlucke.com>2020-01-23 16:21:48 +0300
commit9c9ea37770dcf2d8a77cab0bf267a5bcf76500eb (patch)
tree42949c951e57c88dc34ab62dc79763644aea5848 /tests
parent237d03f3a308efb2155c438ada6feb347472db8c (diff)
Fix: Use a minimal alignment of 8 in MEM_lockfree_mallocN_aligned
`posix_memalign` requires the `alignment` to be at least `sizeof(void *)`. Previously, `MEM_mallocN_aligned` would simply return `NULL` if a too small `alignment` was used. This was an OS specific issue. The solution is to use a minimal alignment of `8` for all aligned allocations. The unit tests have been extended to test more possible alignments (some of which were broken before). Reviewers: brecht Differential Revision: https://developer.blender.org/D6660
Diffstat (limited to 'tests')
-rw-r--r--tests/gtests/guardedalloc/guardedalloc_alignment_test.cc76
1 files changed, 71 insertions, 5 deletions
diff --git a/tests/gtests/guardedalloc/guardedalloc_alignment_test.cc b/tests/gtests/guardedalloc/guardedalloc_alignment_test.cc
index efb29a6088d..4866ac44e3c 100644
--- a/tests/gtests/guardedalloc/guardedalloc_alignment_test.cc
+++ b/tests/gtests/guardedalloc/guardedalloc_alignment_test.cc
@@ -34,6 +34,50 @@ void DoBasicAlignmentChecks(const int alignment)
} // namespace
+TEST(guardedalloc, LockfreeAlignedAlloc1)
+{
+ DoBasicAlignmentChecks(1);
+}
+
+TEST(guardedalloc, GuardedAlignedAlloc1)
+{
+ MEM_use_guarded_allocator();
+ DoBasicAlignmentChecks(1);
+}
+
+TEST(guardedalloc, LockfreeAlignedAlloc2)
+{
+ DoBasicAlignmentChecks(2);
+}
+
+TEST(guardedalloc, GuardedAlignedAlloc2)
+{
+ MEM_use_guarded_allocator();
+ DoBasicAlignmentChecks(2);
+}
+
+TEST(guardedalloc, LockfreeAlignedAlloc4)
+{
+ DoBasicAlignmentChecks(4);
+}
+
+TEST(guardedalloc, GuardedAlignedAlloc4)
+{
+ MEM_use_guarded_allocator();
+ DoBasicAlignmentChecks(4);
+}
+
+TEST(guardedalloc, LockfreeAlignedAlloc8)
+{
+ DoBasicAlignmentChecks(8);
+}
+
+TEST(guardedalloc, GuardedAlignedAlloc8)
+{
+ MEM_use_guarded_allocator();
+ DoBasicAlignmentChecks(8);
+}
+
TEST(guardedalloc, LockfreeAlignedAlloc16)
{
DoBasicAlignmentChecks(16);
@@ -45,13 +89,35 @@ TEST(guardedalloc, GuardedAlignedAlloc16)
DoBasicAlignmentChecks(16);
}
-// On Apple we currently support 16 bit alignment only.
-// Harmless for Blender, but would be nice to support
-// eventually.
-#ifndef __APPLE__
+TEST(guardedalloc, LockfreeAlignedAlloc32)
+{
+ DoBasicAlignmentChecks(32);
+}
+
TEST(guardedalloc, GuardedAlignedAlloc32)
{
MEM_use_guarded_allocator();
DoBasicAlignmentChecks(32);
}
-#endif
+
+TEST(guardedalloc, LockfreeAlignedAlloc256)
+{
+ DoBasicAlignmentChecks(256);
+}
+
+TEST(guardedalloc, GuardedAlignedAlloc256)
+{
+ MEM_use_guarded_allocator();
+ DoBasicAlignmentChecks(256);
+}
+
+TEST(guardedalloc, LockfreeAlignedAlloc512)
+{
+ DoBasicAlignmentChecks(512);
+}
+
+TEST(guardedalloc, GuardedAlignedAlloc512)
+{
+ MEM_use_guarded_allocator();
+ DoBasicAlignmentChecks(512);
+}