summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 05:46:35 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 05:46:35 +0000
commit3ef57580d094c6d7444ba39b0fa944115b901dd4 (patch)
tree2240c53f35f09bbcc738803971089a49fb1b0d05
parent3cb0f8d92d653f4ff8e6886bf6b3a975bd843212 (diff)
downloadchromium_src-3ef57580d094c6d7444ba39b0fa944115b901dd4.zip
chromium_src-3ef57580d094c6d7444ba39b0fa944115b901dd4.tar.gz
chromium_src-3ef57580d094c6d7444ba39b0fa944115b901dd4.tar.bz2
Make StackContainer test pass on Android.
Failure output from experimental Android builder: [ RUN ] StackContainer.BufferAlignment base/stack_container_unittest.cc:126: Failure Value of: reinterpret_cast<uintptr_t>(&aligned256[0]) & (256 - 1) Actual: 80 Expected: 0u Which is: 0 [ FAILED ] StackContainer.BufferAlignment (1 ms) BUG=115612 Review URL: http://codereview.chromium.org/9456032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124126 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/stack_container.h6
-rw-r--r--base/stack_container_unittest.cc10
2 files changed, 14 insertions, 2 deletions
diff --git a/base/stack_container.h b/base/stack_container.h
index 06ef2a4..e2db1c2 100644
--- a/base/stack_container.h
+++ b/base/stack_container.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "build/build_config.h"
#include "base/memory/aligned_memory.h"
// This allocator can be used with STL containers to provide a stack buffer
@@ -53,6 +54,9 @@ class StackAllocator : public std::allocator<T> {
// constructors and destructors to be automatically called. Define a POD
// buffer of the right size instead.
base::AlignedMemory<sizeof(T[stack_capacity]), ALIGNOF(T)> stack_buffer_;
+#if defined(OS_ANDROID)
+ COMPILE_ASSERT(ALIGNOF(T) <= 16, crbug_115612);
+#endif
// Set when the stack buffer is used for an allocation. We do not track
// how much of the buffer is used, only that somebody is using it.
diff --git a/base/stack_container_unittest.cc b/base/stack_container_unittest.cc
index 175df36..798add7 100644
--- a/base/stack_container_unittest.cc
+++ b/base/stack_container_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -121,9 +121,17 @@ TEST(StackContainer, BufferAlignment) {
doubles->push_back(0.0);
EXPECT_ALIGNED(&doubles[0], ALIGNOF(double));
+ StackVector<AlignedData<16>, 1> aligned16;
+ aligned16->push_back(AlignedData<16>());
+ EXPECT_ALIGNED(&aligned16[0], 16);
+
+#if !defined(OS_ANDROID)
+ // It seems that android doesn't respect greater than 16 byte alignment for
+ // non-POD data on the stack, even though ALIGNOF(aligned256) == 256.
StackVector<AlignedData<256>, 1> aligned256;
aligned256->push_back(AlignedData<256>());
EXPECT_ALIGNED(&aligned256[0], 256);
+#endif
}
#ifdef COMPILER_MSVC