aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/OverAlignedTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-09-26 16:51:59 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-09-27 10:33:03 +0000
commited924ceffb07d6f383aeb63eab336df4f13df0f1 (patch)
tree4d51274668c83ed88fe0e0438c369c0a2712f67d /tests/OverAlignedTest.cpp
parent6a259bfcc80a7b4765b99c7503e5a5b98b7e1523 (diff)
Focus -Wno-over-aligned to just 32-bit x86 Android.
I've even found the code that's making this happen, just don't know why. I've added a test to assert that it's safe to assume malloc() is 8-byte aligned. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2662 CQ_INCLUDE_TRYBOTS=master.client.skia.android:Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-GN_Android-Trybot Change-Id: If8a2898ab3a77571622eb125c97f676e029b902c Reviewed-on: https://skia-review.googlesource.com/2662 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'tests/OverAlignedTest.cpp')
-rw-r--r--tests/OverAlignedTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/OverAlignedTest.cpp b/tests/OverAlignedTest.cpp
new file mode 100644
index 0000000000..ed4bb7456d
--- /dev/null
+++ b/tests/OverAlignedTest.cpp
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+#include "SkRandom.h"
+
+// Clang seems to think only 32-bit alignment is guaranteed on 32-bit x86 Android.
+// See https://reviews.llvm.org/D8357
+// This is why we have disabled -Wover-aligned there (we allocate 8-byte aligned structs in Ganesh).
+DEF_TEST(OverAligned, r) {
+ SkRandom rand;
+ // Let's test that assertion. We think it really should be providing 8-byte alignment.
+ for (int i = 0; i < 1000; i++) {
+ void* p = malloc(rand.nextRangeU(0,100));
+ REPORTER_ASSERT(r, SkIsAlign8(p));
+ free(p);
+ }
+}