| 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 #if !defined(OS_WIN) |
| 39 subtle::Atomic32 g_new_handler_lock = 0; | 38 subtle::Atomic32 g_new_handler_lock = 0; |
| 40 #endif | 39 #endif |
| 41 | 40 |
| 42 // In theory this should be just base::ThreadChecker. But we can't afford | 41 // In theory this should be just base::ThreadChecker. But we can't afford |
| 43 // the luxury of a LazyInstance<ThreadChecker> here as it would cause a new(). | 42 // the luxury of a LazyInstance<ThreadChecker> here as it would cause a new(). |
| 44 bool CalledOnValidThread() { | 43 bool CalledOnValidThread() { |
| 45 using subtle::Atomic32; | 44 using subtle::Atomic32; |
| 46 const Atomic32 kInvalidTID = static_cast<Atomic32>(kInvalidThreadId); | 45 const Atomic32 kInvalidTID = static_cast<Atomic32>(kInvalidThreadId); |
| 47 static Atomic32 g_tid = kInvalidTID; | 46 static Atomic32 g_tid = kInvalidTID; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // Cross-checks. | 272 // Cross-checks. |
| 274 | 273 |
| 275 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 274 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 276 #error The allocator shim should not be compiled when building for memory tools. | 275 #error The allocator shim should not be compiled when building for memory tools. |
| 277 #endif | 276 #endif |
| 278 | 277 |
| 279 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ | 278 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ |
| 280 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) | 279 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) |
| 281 #error This code cannot be used when exceptions are turned on. | 280 #error This code cannot be used when exceptions are turned on. |
| 282 #endif | 281 #endif |
| OLD | NEW |