Flutter Engine
The Flutter Engine
OverAlignedTest.cpp
Go to the documentation of this file.
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
11#include "src/base/SkRandom.h"
12#include "tests/Test.h"
13#include <stdint.h>
14
15// Clang seems to think only 32-bit alignment is guaranteed on 32-bit x86 Android.
16// See https://reviews.llvm.org/D8357
17// This is why we have disabled -Wover-aligned there (we allocate 8-byte aligned structs in Ganesh).
18DEF_TEST(OverAligned, r) {
19 SkRandom rand;
20 // Let's test that assertion. We think it really should be providing 8-byte alignment.
21 for (int i = 0; i < 1000; i++) {
22 void* p = sk_malloc_throw(rand.nextRangeU(0,100));
23 REPORTER_ASSERT(r, SkIsAlign8((uintptr_t)p));
24 sk_free(p);
25 }
26}
DEF_TEST(OverAligned, r)
static constexpr bool SkIsAlign8(T x)
Definition: SkAlign.h:21
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
uint32_t nextRangeU(uint32_t min, uint32_t max)
Definition: SkRandom.h:80