Remove base/memory/aligned_memory.*
Similar to https://codereview.chromium.org/2932053002/.
Wasn't used after LazyInstance use was removed previously.
Change-Id: I0a00b0286cc74253a094c61142f39fa1be773d0f
Reviewed-on: https://chromium-review.googlesource.com/529965
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 6b6b43d..4b9a5fe 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -45,8 +45,6 @@
"mac/scoped_nsobject.h",
"mac/scoped_typeref.h",
"macros.h",
- "memory/aligned_memory.cc",
- "memory/aligned_memory.h",
"memory/free_deleter.h",
"memory/ptr_util.h",
"memory/scoped_policy.h",
diff --git a/base/base.gyp b/base/base.gyp
index 9f0f535..bef4df7 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -69,8 +69,6 @@
'mac/scoped_nsobject.h',
'mac/scoped_typeref.h',
'macros.h',
- 'memory/aligned_memory.cc',
- 'memory/aligned_memory.h',
'memory/free_deleter.h',
'memory/ptr_util.h',
'memory/scoped_policy.h',
diff --git a/base/memory/aligned_memory.cc b/base/memory/aligned_memory.cc
deleted file mode 100644
index 7caaf82..0000000
--- a/base/memory/aligned_memory.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 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.
-
-#include "base/memory/aligned_memory.h"
-
-#include "base/logging.h"
-
-#if defined(OS_ANDROID)
-#include <malloc.h>
-#endif
-
-namespace base {
-
-void* AlignedAlloc(size_t size, size_t alignment) {
- DCHECK_GT(size, 0U);
- DCHECK_EQ(alignment & (alignment - 1), 0U);
- DCHECK_EQ(alignment % sizeof(void*), 0U);
- void* ptr = NULL;
-#if defined(COMPILER_MSVC)
- ptr = _aligned_malloc(size, alignment);
-// Android technically supports posix_memalign(), but does not expose it in
-// the current version of the library headers used by Chrome. Luckily,
-// memalign() on Android returns pointers which can safely be used with
-// free(), so we can use it instead. Issue filed to document this:
-// http://code.google.com/p/android/issues/detail?id=35391
-#elif defined(OS_ANDROID)
- ptr = memalign(alignment, size);
-#else
- if (posix_memalign(&ptr, alignment, size))
- ptr = NULL;
-#endif
- // Since aligned allocations may fail for non-memory related reasons, force a
- // crash if we encounter a failed allocation; maintaining consistent behavior
- // with a normal allocation failure in Chrome.
- if (!ptr) {
- CHECK(false);
- }
- // Sanity check alignment just to be safe.
- DCHECK_EQ(reinterpret_cast<uintptr_t>(ptr) & (alignment - 1), 0U);
- return ptr;
-}
-
-} // namespace base
diff --git a/base/memory/aligned_memory.h b/base/memory/aligned_memory.h
deleted file mode 100644
index b74981c..0000000
--- a/base/memory/aligned_memory.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 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.
-
-// AlignedMemory is a POD type that gives you a portable way to specify static
-// or local stack data of a given alignment and size. For example, if you need
-// static storage for a class, but you want manual control over when the object
-// is constructed and destructed (you don't want static initialization and
-// destruction), use AlignedMemory:
-//
-// static AlignedMemory<sizeof(MyClass), ALIGNOF(MyClass)> my_class;
-//
-// // ... at runtime:
-// new(my_class.void_data()) MyClass();
-//
-// // ... use it:
-// MyClass* mc = my_class.data_as<MyClass>();
-//
-// // ... later, to destruct my_class:
-// my_class.data_as<MyClass>()->MyClass::~MyClass();
-//
-// Alternatively, a runtime sized aligned allocation can be created:
-//
-// float* my_array = static_cast<float*>(AlignedAlloc(size, alignment));
-//
-// // ... later, to release the memory:
-// AlignedFree(my_array);
-//
-// Or using unique_ptr:
-//
-// std::unique_ptr<float, AlignedFreeDeleter> my_array(
-// static_cast<float*>(AlignedAlloc(size, alignment)));
-
-#ifndef BASE_MEMORY_ALIGNED_MEMORY_H_
-#define BASE_MEMORY_ALIGNED_MEMORY_H_
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "base/compiler_specific.h"
-
-#if defined(COMPILER_MSVC)
-#include <malloc.h>
-#else
-#include <stdlib.h>
-#endif
-
-namespace base {
-
-// AlignedMemory is specialized for all supported alignments.
-// Make sure we get a compiler error if someone uses an unsupported alignment.
-template <size_t Size, size_t ByteAlignment>
-struct AlignedMemory {};
-
-#define BASE_DECL_ALIGNED_MEMORY(byte_alignment) \
- template <size_t Size> \
- class AlignedMemory<Size, byte_alignment> { \
- public: \
- ALIGNAS(byte_alignment) uint8_t data_[Size]; \
- void* void_data() { return static_cast<void*>(data_); } \
- const void* void_data() const { \
- return static_cast<const void*>(data_); \
- } \
- template<typename Type> \
- Type* data_as() { return static_cast<Type*>(void_data()); } \
- template<typename Type> \
- const Type* data_as() const { \
- return static_cast<const Type*>(void_data()); \
- } \
- private: \
- void* operator new(size_t); \
- void operator delete(void*); \
- }
-
-// Specialization for all alignments is required because MSVC (as of VS 2008)
-// does not understand ALIGNAS(ALIGNOF(Type)) or ALIGNAS(template_param).
-// Greater than 4096 alignment is not supported by some compilers, so 4096 is
-// the maximum specified here.
-BASE_DECL_ALIGNED_MEMORY(1);
-BASE_DECL_ALIGNED_MEMORY(2);
-BASE_DECL_ALIGNED_MEMORY(4);
-BASE_DECL_ALIGNED_MEMORY(8);
-BASE_DECL_ALIGNED_MEMORY(16);
-BASE_DECL_ALIGNED_MEMORY(32);
-BASE_DECL_ALIGNED_MEMORY(64);
-BASE_DECL_ALIGNED_MEMORY(128);
-BASE_DECL_ALIGNED_MEMORY(256);
-BASE_DECL_ALIGNED_MEMORY(512);
-BASE_DECL_ALIGNED_MEMORY(1024);
-BASE_DECL_ALIGNED_MEMORY(2048);
-BASE_DECL_ALIGNED_MEMORY(4096);
-
-#undef BASE_DECL_ALIGNED_MEMORY
-
-void* AlignedAlloc(size_t size, size_t alignment);
-
-inline void AlignedFree(void* ptr) {
-#if defined(COMPILER_MSVC)
- _aligned_free(ptr);
-#else
- free(ptr);
-#endif
-}
-
-// Deleter for use with unique_ptr. E.g., use as
-// std::unique_ptr<Foo, base::AlignedFreeDeleter> foo;
-struct AlignedFreeDeleter {
- inline void operator()(void* ptr) const {
- AlignedFree(ptr);
- }
-};
-
-} // namespace base
-
-#endif // BASE_MEMORY_ALIGNED_MEMORY_H_