Mike Klein | 7bfc08b | 2016-09-27 07:41:45 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "Test.h" |
| 9 | #include "SkRandom.h" |
| 10 | |
| 11 | // Clang seems to think only 32-bit alignment is guaranteed on 32-bit x86 Android. |
| 12 | // See https://reviews.llvm.org/D8357 |
| 13 | // This is why we have disabled -Wover-aligned there (we allocate 8-byte aligned structs in Ganesh). |
| 14 | DEF_TEST(OverAligned, r) { |
| 15 | SkRandom rand; |
| 16 | // Let's test that assertion. We think it really should be providing 8-byte alignment. |
| 17 | for (int i = 0; i < 1000; i++) { |
Mike Klein | 615daf0 | 2016-09-27 11:26:50 -0400 | [diff] [blame] | 18 | void* p = sk_malloc_throw(rand.nextRangeU(0,100)); |
Mike Klein | 7bfc08b | 2016-09-27 07:41:45 -0400 | [diff] [blame] | 19 | REPORTER_ASSERT(r, SkIsAlign8((uintptr_t)p)); |
Mike Klein | 615daf0 | 2016-09-27 11:26:50 -0400 | [diff] [blame] | 20 | sk_free(p); |
Mike Klein | 7bfc08b | 2016-09-27 07:41:45 -0400 | [diff] [blame] | 21 | } |
| 22 | } |