| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/allocator/allocator_shim.h" | 5 #include "base/allocator/allocator_shim.h" |
| 6 | 6 |
| 7 #include <malloc.h> | 7 #include <malloc.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 | 11 |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <new> | 13 #include <new> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/atomicops.h" | 16 #include "base/atomicops.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "base/threading/thread_local.h" | 19 #include "base/threading/thread_local.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 // Some new Android NDKs (64 bit) does not expose (p)valloc anymore. These |
| 24 // functions are implemented at the shim-layer level. |
| 25 #if defined(OS_ANDROID) |
| 26 extern "C" { |
| 27 void* valloc(size_t size); |
| 28 void* pvalloc(size_t size); |
| 29 } |
| 30 #endif |
| 31 |
| 23 namespace base { | 32 namespace base { |
| 24 namespace allocator { | 33 namespace allocator { |
| 25 namespace { | 34 namespace { |
| 26 | 35 |
| 27 using testing::MockFunction; | 36 using testing::MockFunction; |
| 28 using testing::_; | 37 using testing::_; |
| 29 | 38 |
| 30 class AllocatorShimTest : public testing::Test { | 39 class AllocatorShimTest : public testing::Test { |
| 31 public: | 40 public: |
| 32 static const size_t kMaxSizeTracked = 8192; | 41 static const size_t kMaxSizeTracked = 8192; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 event.Signal(); | 314 event.Signal(); |
| 306 for (int i = 0; i < kNumThreads; ++i) | 315 for (int i = 0; i < kNumThreads; ++i) |
| 307 PlatformThread::Join(threads[i]); | 316 PlatformThread::Join(threads[i]); |
| 308 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); | 317 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); |
| 309 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); | 318 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); |
| 310 } | 319 } |
| 311 | 320 |
| 312 } // namespace | 321 } // namespace |
| 313 } // namespace allocator | 322 } // namespace allocator |
| 314 } // namespace base | 323 } // namespace base |
| OLD | NEW |