OLD | NEW |
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 Loading... |
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 "../include/v8stdint.h" | 33 #include "globals.h" |
| 34 |
34 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); | 35 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); |
35 | 36 |
36 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during | 37 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during |
37 // development, but they should not be relied on in the final product. | 38 // development, but they should not be relied on in the final product. |
38 #ifdef DEBUG | 39 #ifdef DEBUG |
39 #define FATAL(msg) \ | 40 #define FATAL(msg) \ |
40 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) | 41 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) |
41 #define UNIMPLEMENTED() \ | 42 #define UNIMPLEMENTED() \ |
42 V8_Fatal(__FILE__, __LINE__, "unimplemented code") | 43 V8_Fatal(__FILE__, __LINE__, "unimplemented code") |
43 #define UNREACHABLE() \ | 44 #define UNREACHABLE() \ |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 226 |
226 | 227 |
227 #define CHECK_GT(a, b) CHECK((a) > (b)) | 228 #define CHECK_GT(a, b) CHECK((a) > (b)) |
228 #define CHECK_GE(a, b) CHECK((a) >= (b)) | 229 #define CHECK_GE(a, b) CHECK((a) >= (b)) |
229 #define CHECK_LT(a, b) CHECK((a) < (b)) | 230 #define CHECK_LT(a, b) CHECK((a) < (b)) |
230 #define CHECK_LE(a, b) CHECK((a) <= (b)) | 231 #define CHECK_LE(a, b) CHECK((a) <= (b)) |
231 | 232 |
232 | 233 |
233 // Use C++11 static_assert if possible, which gives error | 234 // Use C++11 static_assert if possible, which gives error |
234 // messages that are easier to understand on first sight. | 235 // messages that are easier to understand on first sight. |
235 #if __cplusplus >= 201103L | 236 #if defined(V8_HAVE_CXX11_STATIC_ASSERT) |
236 #define STATIC_CHECK(test) static_assert(test, #test) | 237 #define STATIC_CHECK(test) static_assert(test, #test) |
237 #else | 238 #else |
238 // This is inspired by the static assertion facility in boost. This | 239 // 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 | 240 // is pretty magical. If it causes you trouble on a platform you may |
240 // find a fix in the boost code. | 241 // find a fix in the boost code. |
241 template <bool> class StaticAssertion; | 242 template <bool> class StaticAssertion; |
242 template <> class StaticAssertion<true> { }; | 243 template <> class StaticAssertion<true> { }; |
243 // This macro joins two tokens. If one of the tokens is a macro the | 244 // This macro joins two tokens. If one of the tokens is a macro the |
244 // helper call causes it to be resolved before joining. | 245 // helper call causes it to be resolved before joining. |
245 #define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b) | 246 #define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 293 |
293 // "Extra checks" are lightweight checks that are enabled in some release | 294 // "Extra checks" are lightweight checks that are enabled in some release |
294 // builds. | 295 // builds. |
295 #ifdef ENABLE_EXTRA_CHECKS | 296 #ifdef ENABLE_EXTRA_CHECKS |
296 #define EXTRA_CHECK(condition) CHECK(condition) | 297 #define EXTRA_CHECK(condition) CHECK(condition) |
297 #else | 298 #else |
298 #define EXTRA_CHECK(condition) ((void) 0) | 299 #define EXTRA_CHECK(condition) ((void) 0) |
299 #endif | 300 #endif |
300 | 301 |
301 #endif // V8_CHECKS_H_ | 302 #endif // V8_CHECKS_H_ |
OLD | NEW |