blob: fcc3e16ef56c6ef40fbf704289596dac432ec08c [file] [log] [blame]
Mike Klein7bfc08b2016-09-27 07:41:45 -04001/*
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).
14DEF_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 Klein615daf02016-09-27 11:26:50 -040018 void* p = sk_malloc_throw(rand.nextRangeU(0,100));
Mike Klein7bfc08b2016-09-27 07:41:45 -040019 REPORTER_ASSERT(r, SkIsAlign8((uintptr_t)p));
Mike Klein615daf02016-09-27 11:26:50 -040020 sk_free(p);
Mike Klein7bfc08b2016-09-27 07:41:45 -040021 }
22}