Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1)) | 159 EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1)) |
| 160 | 160 |
| 161 TEST(LazyInstanceTest, Alignment) { | 161 TEST(LazyInstanceTest, Alignment) { |
| 162 using base::LazyInstance; | 162 using base::LazyInstance; |
| 163 | 163 |
| 164 // Create some static instances with increasing sizes and alignment | 164 // Create some static instances with increasing sizes and alignment |
| 165 // requirements. By ordering this way, the linker will need to do some work to | 165 // requirements. By ordering this way, the linker will need to do some work to |
| 166 // ensure proper alignment of the static data. | 166 // ensure proper alignment of the static data. |
| 167 static LazyInstance<AlignedData<4> > align4 = LAZY_INSTANCE_INITIALIZER; | 167 static LazyInstance<AlignedData<4> > align4 = LAZY_INSTANCE_INITIALIZER; |
| 168 static LazyInstance<AlignedData<32> > align32 = LAZY_INSTANCE_INITIALIZER; | 168 static LazyInstance<AlignedData<32> > align32 = LAZY_INSTANCE_INITIALIZER; |
| 169 // GCC doesn't like alignment >64 on ARM. | |
|
danakj
2017/02/08 21:29:47
Honest question is it worth testing this if nothin
dcheng
2017/02/09 00:01:24
I don't feel strongly about this; I'm happy to jus
| |
| 170 #if !defined(ARCH_CPU_ARM_FAMILY) || defined(__clang__) | |
| 169 static LazyInstance<AlignedData<4096> > align4096 = LAZY_INSTANCE_INITIALIZER; | 171 static LazyInstance<AlignedData<4096> > align4096 = LAZY_INSTANCE_INITIALIZER; |
| 172 #endif | |
| 170 | 173 |
| 171 EXPECT_ALIGNED(align4.Pointer(), 4); | 174 EXPECT_ALIGNED(align4.Pointer(), 4); |
| 172 EXPECT_ALIGNED(align32.Pointer(), 32); | 175 EXPECT_ALIGNED(align32.Pointer(), 32); |
| 176 // GCC doesn't like alignment >64 on ARM. | |
| 177 #if !defined(ARCH_CPU_ARM_FAMILY) || defined(__clang__) | |
| 173 EXPECT_ALIGNED(align4096.Pointer(), 4096); | 178 EXPECT_ALIGNED(align4096.Pointer(), 4096); |
| 179 #endif | |
| 174 } | 180 } |
| OLD | NEW |