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 <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include <new> | 9 #include <new> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // they are safe to use today, in future they might be refactored. | 27 // they are safe to use today, in future they might be refactored. |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 using namespace base; | 31 using namespace base; |
32 | 32 |
33 subtle::AtomicWord g_chain_head = reinterpret_cast<subtle::AtomicWord>( | 33 subtle::AtomicWord g_chain_head = reinterpret_cast<subtle::AtomicWord>( |
34 &allocator::AllocatorDispatch::default_dispatch); | 34 &allocator::AllocatorDispatch::default_dispatch); |
35 | 35 |
36 bool g_call_new_handler_on_malloc_failure = false; | 36 bool g_call_new_handler_on_malloc_failure = false; |
| 37 |
| 38 #if !defined(OS_WIN) |
37 subtle::Atomic32 g_new_handler_lock = 0; | 39 subtle::Atomic32 g_new_handler_lock = 0; |
| 40 #endif |
38 | 41 |
39 // In theory this should be just base::ThreadChecker. But we can't afford | 42 // In theory this should be just base::ThreadChecker. But we can't afford |
40 // the luxury of a LazyInstance<ThreadChecker> here as it would cause a new(). | 43 // the luxury of a LazyInstance<ThreadChecker> here as it would cause a new(). |
41 bool CalledOnValidThread() { | 44 bool CalledOnValidThread() { |
42 using subtle::Atomic32; | 45 using subtle::Atomic32; |
43 const Atomic32 kInvalidTID = static_cast<Atomic32>(kInvalidThreadId); | 46 const Atomic32 kInvalidTID = static_cast<Atomic32>(kInvalidThreadId); |
44 static Atomic32 g_tid = kInvalidTID; | 47 static Atomic32 g_tid = kInvalidTID; |
45 Atomic32 cur_tid = static_cast<Atomic32>(PlatformThread::CurrentId()); | 48 Atomic32 cur_tid = static_cast<Atomic32>(PlatformThread::CurrentId()); |
46 Atomic32 prev_tid = | 49 Atomic32 prev_tid = |
47 subtle::NoBarrier_CompareAndSwap(&g_tid, kInvalidTID, cur_tid); | 50 subtle::NoBarrier_CompareAndSwap(&g_tid, kInvalidTID, cur_tid); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Cross-checks. | 273 // Cross-checks. |
271 | 274 |
272 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 275 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
273 #error The allocator shim should not be compiled when building for memory tools. | 276 #error The allocator shim should not be compiled when building for memory tools. |
274 #endif | 277 #endif |
275 | 278 |
276 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ | 279 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ |
277 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) | 280 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) |
278 #error This code cannot be used when exceptions are turned on. | 281 #error This code cannot be used when exceptions are turned on. |
279 #endif | 282 #endif |
OLD | NEW |