Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: base/logging.h

Issue 2518253002: Move Partition Allocator into Chromium base. (Closed)
Patch Set: Move OOM_CRASH into its own, more specific header. Fixes Windows build. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 std::string* message_; 459 std::string* message_;
460 }; 460 };
461 461
462 // Crashes in the fastest, simplest possible way with no attempt at logging. 462 // Crashes in the fastest, simplest possible way with no attempt at logging.
463 #if defined(COMPILER_GCC) || defined(__clang__) 463 #if defined(COMPILER_GCC) || defined(__clang__)
464 #define IMMEDIATE_CRASH() __builtin_trap() 464 #define IMMEDIATE_CRASH() __builtin_trap()
465 #else 465 #else
466 #define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0)) 466 #define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
467 #endif 467 #endif
468 468
469 // Specialization of IMMEDIATE_CRASH which will raise a custom exception on
470 // Windows to signal this is OOM and not a normal assert.
471 #if defined(OS_WIN)
472 #define OOM_CRASH() \
473 do { \
474 ::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \
475 IMMEDIATE_CRASH(); \
476 } while (0)
477 #else
478 #define OOM_CRASH() IMMEDIATE_CRASH()
479 #endif
480
481 // CHECK dies with a fatal error if condition is not true. It is *not* 469 // CHECK dies with a fatal error if condition is not true. It is *not*
482 // controlled by NDEBUG, so the check will be executed regardless of 470 // controlled by NDEBUG, so the check will be executed regardless of
483 // compilation mode. 471 // compilation mode.
484 // 472 //
485 // We make sure CHECK et al. always evaluates their arguments, as 473 // We make sure CHECK et al. always evaluates their arguments, as
486 // doing CHECK(FunctionWithSideEffect()) is a common idiom. 474 // doing CHECK(FunctionWithSideEffect()) is a common idiom.
487 475
488 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) 476 #if defined(OFFICIAL_BUILD) && defined(NDEBUG)
489 477
490 // Make all CHECK functions discard their log strings to reduce code bloat, and 478 // Make all CHECK functions discard their log strings to reduce code bloat, and
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 #elif NOTIMPLEMENTED_POLICY == 5 1017 #elif NOTIMPLEMENTED_POLICY == 5
1030 #define NOTIMPLEMENTED() do {\ 1018 #define NOTIMPLEMENTED() do {\
1031 static bool logged_once = false;\ 1019 static bool logged_once = false;\
1032 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1020 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1033 logged_once = true;\ 1021 logged_once = true;\
1034 } while(0);\ 1022 } while(0);\
1035 EAT_STREAM_PARAMETERS 1023 EAT_STREAM_PARAMETERS
1036 #endif 1024 #endif
1037 1025
1038 #endif // BASE_LOGGING_H_ 1026 #endif // BASE_LOGGING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698