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 static LazyInstance<AlignedData<4096> > align4096 = LAZY_INSTANCE_INITIALIZER; | 169 static LazyInstance<AlignedData<64>> align64 = LAZY_INSTANCE_INITIALIZER; |
170 | 170 |
171 EXPECT_ALIGNED(align4.Pointer(), 4); | 171 EXPECT_ALIGNED(align4.Pointer(), 4); |
172 EXPECT_ALIGNED(align32.Pointer(), 32); | 172 EXPECT_ALIGNED(align32.Pointer(), 32); |
173 EXPECT_ALIGNED(align4096.Pointer(), 4096); | 173 EXPECT_ALIGNED(align64.Pointer(), 64); |
174 } | 174 } |
OLD | NEW |