OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 bool condition) { | 58 bool condition) { |
59 if (!condition) | 59 if (!condition) |
60 V8_Fatal(file, line, "CHECK(%s) failed", source); | 60 V8_Fatal(file, line, "CHECK(%s) failed", source); |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 // The CHECK macro checks that the given condition is true; if not, it | 64 // The CHECK macro checks that the given condition is true; if not, it |
65 // prints a message to stderr and aborts. | 65 // prints a message to stderr and aborts. |
66 #define CHECK(condition) do { \ | 66 #define CHECK(condition) do { \ |
67 if (!(condition)) CheckHelper(__FILE__, __LINE__, #condition, false); \ | 67 if (!(condition)) CheckHelper(__FILE__, __LINE__, #condition, false); \ |
68 } while(0) | 68 } while (0) |
69 | 69 |
70 | 70 |
71 // Helper function used by the CHECK_EQ function when given int | 71 // Helper function used by the CHECK_EQ function when given int |
72 // arguments. Should not be called directly. | 72 // arguments. Should not be called directly. |
73 static inline void CheckEqualsHelper(const char* file, int line, | 73 static inline void CheckEqualsHelper(const char* file, int line, |
74 const char* expected_source, int expected, | 74 const char* expected_source, int expected, |
75 const char* value_source, int value) { | 75 const char* value_source, int value) { |
76 if (expected != value) { | 76 if (expected != value) { |
77 V8_Fatal(file, line, | 77 V8_Fatal(file, line, |
78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", | 78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // Static asserts has no impact on runtime performance, so they can be | 286 // Static asserts has no impact on runtime performance, so they can be |
287 // safely enabled in release mode. Moreover, the ((void) 0) expression | 287 // safely enabled in release mode. Moreover, the ((void) 0) expression |
288 // obeys different syntax rules than typedef's, e.g. it can't appear | 288 // obeys different syntax rules than typedef's, e.g. it can't appear |
289 // inside class declaration, this leads to inconsistency between debug | 289 // inside class declaration, this leads to inconsistency between debug |
290 // and release compilation modes behavior. | 290 // and release compilation modes behavior. |
291 #define STATIC_ASSERT(test) STATIC_CHECK(test) | 291 #define STATIC_ASSERT(test) STATIC_CHECK(test) |
292 | 292 |
293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) | 293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) |
294 | 294 |
295 #endif // V8_CHECKS_H_ | 295 #endif // V8_CHECKS_H_ |
OLD | NEW |