| 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> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 uint64_t ignored; | 151 uint64_t ignored; |
| 152 uint8_t ignored_3; | 152 uint8_t ignored_3; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 class ThreadDelegateForNewHandlerTest : public PlatformThread::Delegate { | 155 class ThreadDelegateForNewHandlerTest : public PlatformThread::Delegate { |
| 156 public: | 156 public: |
| 157 ThreadDelegateForNewHandlerTest(WaitableEvent* event) : event_(event) {} | 157 ThreadDelegateForNewHandlerTest(WaitableEvent* event) : event_(event) {} |
| 158 | 158 |
| 159 void ThreadMain() override { | 159 void ThreadMain() override { |
| 160 event_->Wait(); | 160 event_->Wait(); |
| 161 void* res = realloc(reinterpret_cast<void*>(0x42ul), 1); | 161 |
| 162 // volatile to ensure the compiler doesn't optimize away the equality check |
| 163 void* volatile res = realloc(reinterpret_cast<void*>(0x42ul), 1); |
| 162 EXPECT_EQ(0x42u, reinterpret_cast<uintptr_t>(res)); | 164 EXPECT_EQ(0x42u, reinterpret_cast<uintptr_t>(res)); |
| 163 } | 165 } |
| 164 | 166 |
| 165 private: | 167 private: |
| 166 WaitableEvent* event_; | 168 WaitableEvent* event_; |
| 167 }; | 169 }; |
| 168 | 170 |
| 169 AllocatorShimTest* AllocatorShimTest::instance_ = nullptr; | 171 AllocatorShimTest* AllocatorShimTest::instance_ = nullptr; |
| 170 | 172 |
| 171 AllocatorDispatch g_mock_dispatch = { | 173 AllocatorDispatch g_mock_dispatch = { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 event.Signal(); | 317 event.Signal(); |
| 316 for (int i = 0; i < kNumThreads; ++i) | 318 for (int i = 0; i < kNumThreads; ++i) |
| 317 PlatformThread::Join(threads[i]); | 319 PlatformThread::Join(threads[i]); |
| 318 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); | 320 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); |
| 319 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); | 321 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); |
| 320 } | 322 } |
| 321 | 323 |
| 322 } // namespace | 324 } // namespace |
| 323 } // namespace allocator | 325 } // namespace allocator |
| 324 } // namespace base | 326 } // namespace base |
| OLD | NEW |