blob: 879947eb67ef0e4ad0d33250311d5669c2d126dd [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/utils/SkRandom.h"
9#include "tests/Test.h"
Mike Klein7bfc08b2016-09-27 07:41:45 -040010
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}