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

Side by Side Diff: src/checks.h

Issue 21223003: Reland initial bits of "Implement correct OS and CC detection." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/globals.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_CHECKS_H_ 28 #ifndef V8_CHECKS_H_
29 #define V8_CHECKS_H_ 29 #define V8_CHECKS_H_
30 30
31 #include <string.h> 31 #include <string.h>
32 32
33 #include "globals.h"
34
33 #include "../include/v8stdint.h" 35 #include "../include/v8stdint.h"
34 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); 36 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...);
35 37
36 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during 38 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during
37 // development, but they should not be relied on in the final product. 39 // development, but they should not be relied on in the final product.
38 #ifdef DEBUG 40 #ifdef DEBUG
39 #define FATAL(msg) \ 41 #define FATAL(msg) \
40 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) 42 V8_Fatal(__FILE__, __LINE__, "%s", (msg))
41 #define UNIMPLEMENTED() \ 43 #define UNIMPLEMENTED() \
42 V8_Fatal(__FILE__, __LINE__, "unimplemented code") 44 V8_Fatal(__FILE__, __LINE__, "unimplemented code")
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 227
226 228
227 #define CHECK_GT(a, b) CHECK((a) > (b)) 229 #define CHECK_GT(a, b) CHECK((a) > (b))
228 #define CHECK_GE(a, b) CHECK((a) >= (b)) 230 #define CHECK_GE(a, b) CHECK((a) >= (b))
229 #define CHECK_LT(a, b) CHECK((a) < (b)) 231 #define CHECK_LT(a, b) CHECK((a) < (b))
230 #define CHECK_LE(a, b) CHECK((a) <= (b)) 232 #define CHECK_LE(a, b) CHECK((a) <= (b))
231 233
232 234
233 // Use C++11 static_assert if possible, which gives error 235 // Use C++11 static_assert if possible, which gives error
234 // messages that are easier to understand on first sight. 236 // messages that are easier to understand on first sight.
235 #if __cplusplus >= 201103L 237 #if V8_CXX_STATIC_ASSERT
236 #define STATIC_CHECK(test) static_assert(test, #test) 238 #define STATIC_CHECK(test) static_assert(test, #test)
237 #else 239 #else
238 // This is inspired by the static assertion facility in boost. This 240 // This is inspired by the static assertion facility in boost. This
239 // is pretty magical. If it causes you trouble on a platform you may 241 // is pretty magical. If it causes you trouble on a platform you may
240 // find a fix in the boost code. 242 // find a fix in the boost code.
241 template <bool> class StaticAssertion; 243 template <bool> class StaticAssertion;
242 template <> class StaticAssertion<true> { }; 244 template <> class StaticAssertion<true> { };
243 // This macro joins two tokens. If one of the tokens is a macro the 245 // This macro joins two tokens. If one of the tokens is a macro the
244 // helper call causes it to be resolved before joining. 246 // helper call causes it to be resolved before joining.
245 #define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b) 247 #define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b)
246 #define SEMI_STATIC_JOIN_HELPER(a, b) a##b 248 #define SEMI_STATIC_JOIN_HELPER(a, b) a##b
247 // Causes an error during compilation of the condition is not 249 // Causes an error during compilation of the condition is not
248 // statically known to be true. It is formulated as a typedef so that 250 // statically known to be true. It is formulated as a typedef so that
249 // it can be used wherever a typedef can be used. Beware that this 251 // it can be used wherever a typedef can be used. Beware that this
250 // actually causes each use to introduce a new defined type with a 252 // actually causes each use to introduce a new defined type with a
251 // name depending on the source line. 253 // name depending on the source line.
252 template <int> class StaticAssertionHelper { }; 254 template <int> class StaticAssertionHelper { };
253 #define STATIC_CHECK(test) \ 255 #define STATIC_CHECK(test) \
254 typedef \ 256 typedef \
255 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \ 257 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
256 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) 258 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
257 #endif 259 #endif // V8_CXX_STATIC_ASSERT
258 260
259 261
260 extern bool FLAG_enable_slow_asserts; 262 extern bool FLAG_enable_slow_asserts;
261 263
262 264
263 // The ASSERT macro is equivalent to CHECK except that it only 265 // The ASSERT macro is equivalent to CHECK except that it only
264 // generates code in debug builds. 266 // generates code in debug builds.
265 #ifdef DEBUG 267 #ifdef DEBUG
266 #define ASSERT_RESULT(expr) CHECK(expr) 268 #define ASSERT_RESULT(expr) CHECK(expr)
267 #define ASSERT(condition) CHECK(condition) 269 #define ASSERT(condition) CHECK(condition)
(...skipping 24 matching lines...) Expand all
292 294
293 // "Extra checks" are lightweight checks that are enabled in some release 295 // "Extra checks" are lightweight checks that are enabled in some release
294 // builds. 296 // builds.
295 #ifdef ENABLE_EXTRA_CHECKS 297 #ifdef ENABLE_EXTRA_CHECKS
296 #define EXTRA_CHECK(condition) CHECK(condition) 298 #define EXTRA_CHECK(condition) CHECK(condition)
297 #else 299 #else
298 #define EXTRA_CHECK(condition) ((void) 0) 300 #define EXTRA_CHECK(condition) ((void) 0)
299 #endif 301 #endif
300 302
301 #endif // V8_CHECKS_H_ 303 #endif // V8_CHECKS_H_
OLDNEW
« no previous file with comments | « no previous file | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698