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

Side by Side Diff: src/base/logging.h

Issue 2396933002: Revert of Reland "Turn libbase into a component" (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « src/base/ieee754.h ('k') | src/base/once.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 V8_BASE_LOGGING_H_ 5 #ifndef V8_BASE_LOGGING_H_
6 #define V8_BASE_LOGGING_H_ 6 #define V8_BASE_LOGGING_H_
7 7
8 #include <cstring> 8 #include <cstring>
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
11 11
12 #include "src/base/base-export.h"
13 #include "src/base/build_config.h" 12 #include "src/base/build_config.h"
14 #include "src/base/compiler-specific.h" 13 #include "src/base/compiler-specific.h"
15 14
16 extern "C" PRINTF_FORMAT(3, 4) V8_NORETURN V8_BASE_EXPORT 15 extern "C" PRINTF_FORMAT(3, 4) V8_NORETURN
17 void V8_Fatal(const char* file, int line, const char* format, ...); 16 void V8_Fatal(const char* file, int line, const char* format, ...);
18 17
19 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during 18 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during
20 // development, but they should not be relied on in the final product. 19 // development, but they should not be relied on in the final product.
21 #ifdef DEBUG 20 #ifdef DEBUG
22 #define FATAL(msg) \ 21 #define FATAL(msg) \
23 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) 22 V8_Fatal(__FILE__, __LINE__, "%s", (msg))
24 #define UNIMPLEMENTED() \ 23 #define UNIMPLEMENTED() \
25 V8_Fatal(__FILE__, __LINE__, "unimplemented code") 24 V8_Fatal(__FILE__, __LINE__, "unimplemented code")
26 #define UNREACHABLE() \ 25 #define UNREACHABLE() \
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 template <typename Lhs, typename Rhs> 80 template <typename Lhs, typename Rhs>
82 std::string* MakeCheckOpString(Lhs const& lhs, Rhs const& rhs, 81 std::string* MakeCheckOpString(Lhs const& lhs, Rhs const& rhs,
83 char const* msg) { 82 char const* msg) {
84 std::ostringstream ss; 83 std::ostringstream ss;
85 ss << msg << " (" << lhs << " vs. " << rhs << ")"; 84 ss << msg << " (" << lhs << " vs. " << rhs << ")";
86 return new std::string(ss.str()); 85 return new std::string(ss.str());
87 } 86 }
88 87
89 // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated 88 // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
90 // in logging.cc. 89 // in logging.cc.
91 #define DEFINE_MAKE_CHECK_OP_STRING(type) \ 90 #define DEFINE_MAKE_CHECK_OP_STRING(type) \
92 extern template V8_BASE_EXPORT std::string* MakeCheckOpString<type, type>( \ 91 extern template std::string* MakeCheckOpString<type, type>( \
93 type const&, type const&, char const*); 92 type const&, type const&, char const*);
94 DEFINE_MAKE_CHECK_OP_STRING(int) 93 DEFINE_MAKE_CHECK_OP_STRING(int)
95 DEFINE_MAKE_CHECK_OP_STRING(long) // NOLINT(runtime/int) 94 DEFINE_MAKE_CHECK_OP_STRING(long) // NOLINT(runtime/int)
96 DEFINE_MAKE_CHECK_OP_STRING(long long) // NOLINT(runtime/int) 95 DEFINE_MAKE_CHECK_OP_STRING(long long) // NOLINT(runtime/int)
97 DEFINE_MAKE_CHECK_OP_STRING(unsigned int) 96 DEFINE_MAKE_CHECK_OP_STRING(unsigned int)
98 DEFINE_MAKE_CHECK_OP_STRING(unsigned long) // NOLINT(runtime/int) 97 DEFINE_MAKE_CHECK_OP_STRING(unsigned long) // NOLINT(runtime/int)
99 DEFINE_MAKE_CHECK_OP_STRING(unsigned long long) // NOLINT(runtime/int) 98 DEFINE_MAKE_CHECK_OP_STRING(unsigned long long) // NOLINT(runtime/int)
100 DEFINE_MAKE_CHECK_OP_STRING(char const*) 99 DEFINE_MAKE_CHECK_OP_STRING(char const*)
101 DEFINE_MAKE_CHECK_OP_STRING(void const*) 100 DEFINE_MAKE_CHECK_OP_STRING(void const*)
102 #undef DEFINE_MAKE_CHECK_OP_STRING 101 #undef DEFINE_MAKE_CHECK_OP_STRING
103 102
104 103
105 // Helper functions for CHECK_OP macro. 104 // Helper functions for CHECK_OP macro.
106 // The (int, int) specialization works around the issue that the compiler 105 // The (int, int) specialization works around the issue that the compiler
107 // will not instantiate the template version of the function on values of 106 // will not instantiate the template version of the function on values of
108 // unnamed enum type - see comment below. 107 // unnamed enum type - see comment below.
109 // The (float, float) and (double, double) instantiations are explicitly 108 // The (float, float) and (double, double) instantiations are explicitly
110 // externialized to ensure proper 32/64-bit comparisons on x86. 109 // externialized to ensure proper 32/64-bit comparisons on x86.
111 #define DEFINE_CHECK_OP_IMPL(NAME, op) \ 110 #define DEFINE_CHECK_OP_IMPL(NAME, op) \
112 template <typename Lhs, typename Rhs> \ 111 template <typename Lhs, typename Rhs> \
113 V8_INLINE std::string* Check##NAME##Impl(Lhs const& lhs, Rhs const& rhs, \ 112 V8_INLINE std::string* Check##NAME##Impl(Lhs const& lhs, Rhs const& rhs, \
114 char const* msg) { \ 113 char const* msg) { \
115 return V8_LIKELY(lhs op rhs) ? nullptr : MakeCheckOpString(lhs, rhs, msg); \ 114 return V8_LIKELY(lhs op rhs) ? nullptr : MakeCheckOpString(lhs, rhs, msg); \
116 } \ 115 } \
117 V8_INLINE std::string* Check##NAME##Impl(int lhs, int rhs, \ 116 V8_INLINE std::string* Check##NAME##Impl(int lhs, int rhs, \
118 char const* msg) { \ 117 char const* msg) { \
119 return V8_LIKELY(lhs op rhs) ? nullptr : MakeCheckOpString(lhs, rhs, msg); \ 118 return V8_LIKELY(lhs op rhs) ? nullptr : MakeCheckOpString(lhs, rhs, msg); \
120 } \ 119 } \
121 extern template V8_BASE_EXPORT std::string* Check##NAME##Impl<float, float>( \ 120 extern template std::string* Check##NAME##Impl<float, float>( \
122 float const& lhs, float const& rhs, char const* msg); \ 121 float const& lhs, float const& rhs, char const* msg); \
123 extern template V8_BASE_EXPORT std::string* \ 122 extern template std::string* Check##NAME##Impl<double, double>( \
124 Check##NAME##Impl<double, double>(double const& lhs, double const& rhs, \ 123 double const& lhs, double const& rhs, char const* msg);
125 char const* msg);
126 DEFINE_CHECK_OP_IMPL(EQ, ==) 124 DEFINE_CHECK_OP_IMPL(EQ, ==)
127 DEFINE_CHECK_OP_IMPL(NE, !=) 125 DEFINE_CHECK_OP_IMPL(NE, !=)
128 DEFINE_CHECK_OP_IMPL(LE, <=) 126 DEFINE_CHECK_OP_IMPL(LE, <=)
129 DEFINE_CHECK_OP_IMPL(LT, < ) 127 DEFINE_CHECK_OP_IMPL(LT, < )
130 DEFINE_CHECK_OP_IMPL(GE, >=) 128 DEFINE_CHECK_OP_IMPL(GE, >=)
131 DEFINE_CHECK_OP_IMPL(GT, > ) 129 DEFINE_CHECK_OP_IMPL(GT, > )
132 #undef DEFINE_CHECK_OP_IMPL 130 #undef DEFINE_CHECK_OP_IMPL
133 131
134 #define CHECK_EQ(lhs, rhs) CHECK_OP(EQ, ==, lhs, rhs) 132 #define CHECK_EQ(lhs, rhs) CHECK_OP(EQ, ==, lhs, rhs)
135 #define CHECK_NE(lhs, rhs) CHECK_OP(NE, !=, lhs, rhs) 133 #define CHECK_NE(lhs, rhs) CHECK_OP(NE, !=, lhs, rhs)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 #define DCHECK_GT(v1, v2) ((void) 0) 168 #define DCHECK_GT(v1, v2) ((void) 0)
171 #define DCHECK_GE(v1, v2) ((void) 0) 169 #define DCHECK_GE(v1, v2) ((void) 0)
172 #define DCHECK_LT(v1, v2) ((void) 0) 170 #define DCHECK_LT(v1, v2) ((void) 0)
173 #define DCHECK_LE(v1, v2) ((void) 0) 171 #define DCHECK_LE(v1, v2) ((void) 0)
174 #define DCHECK_NULL(val) ((void) 0) 172 #define DCHECK_NULL(val) ((void) 0)
175 #define DCHECK_NOT_NULL(val) ((void) 0) 173 #define DCHECK_NOT_NULL(val) ((void) 0)
176 #define DCHECK_IMPLIES(v1, v2) ((void) 0) 174 #define DCHECK_IMPLIES(v1, v2) ((void) 0)
177 #endif 175 #endif
178 176
179 #endif // V8_BASE_LOGGING_H_ 177 #endif // V8_BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « src/base/ieee754.h ('k') | src/base/once.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698