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

Unified Diff: src/checks.h

Issue 256048: Add CHECK_INT64_EQ function to avoid operand size ambiguities. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/checks.h
===================================================================
--- src/checks.h (revision 3015)
+++ src/checks.h (working copy)
@@ -80,17 +80,18 @@
}
}
-#if !V8_HOST_ARCH_64_BIT
-// Helper function used by the CHECK_EQ function when given int64_t
-// arguments. Should not be called directly.
-static inline void CheckEqualsHelper(const char* file, int line,
- const char* expected_source,
- int64_t expected,
- const char* value_source,
- int64_t value) {
+// Helper function used by the CHECK_INT64_EQ function when given int64_t
+// arguments. Should not be called directly. We do not overload CHECK_EQ
+// with both 32-bit and 64-bit integers, because it causes ambiguity
+// with operands of mixed sizes.
+static inline void CheckInt64EqualsHelper(const char* file, int line,
+ const char* expected_source,
+ int64_t expected,
+ const char* value_source,
+ int64_t value) {
if (expected != value) {
- // Sorry, printing int64_t in a fanky hex way,
- // that's our mother tongue after all :)
+ // Print int64_t values in hex, as two int32s,
+ // to avoid platform-dependencies.
V8_Fatal(file, line,
"CHECK_EQ(%s, %s) failed\n#"
" Expected: 0x%08x%08x\n# Found: 0x%08x%08x",
@@ -99,7 +100,6 @@
uint32_t(value >> 32), uint32_t(value));
}
}
-#endif
// Helper function used by the CHECK_NE function when given int
@@ -233,7 +233,10 @@
#define CHECK_GT(a, b) CHECK((a) > (b))
#define CHECK_GE(a, b) CHECK((a) >= (b))
+#define CHECK_INT64_EQ(expected, value) CheckInt64EqualsHelper(__FILE__, \
+ __LINE__, #expected, expected, #value, value)
+
// This is inspired by the static assertion facility in boost. This
// is pretty magical. If it causes you trouble on a platform you may
// find a fix in the boost code.
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698