]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Tidying up of branch-predict hint macros LIKELY/UNLIKELY. Fixes
authorJulian Seward <jseward@acm.org>
Mon, 9 May 2011 21:54:44 +0000 (21:54 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 9 May 2011 21:54:44 +0000 (21:54 +0000)
#271504.  (Florian Krohm, britzel@acm.org)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11736

coregrind/pub_core_libcassert.h
include/pub_tool_basics.h
include/pub_tool_libcassert.h

index 3512100a060d95ec02787002d8ed0c522f7de7c0..427bd5f5271506fe63d1d39b190faa868303dd14 100644 (file)
                      "valgrind", VG_BUGS_TO, "")
 
 #define vg_assert(expr)                                                 \
-  ((void) ((expr) ? 0 :                                                 \
+  ((void) (LIKELY(expr) ? 0 :                                           \
            (VG_(assert_fail) (/*isCore*/True, #expr,                    \
                               __FILE__, __LINE__, __PRETTY_FUNCTION__,  \
                               ""),                                      \
                               0)))
 
 #define vg_assert2(expr, format, args...)                               \
-  ((void) ((expr) ? 0 :                                                 \
+  ((void) (LIKELY(expr) ? 0 :                                           \
            (VG_(assert_fail) (/*isCore*/True, #expr,                    \
                               __FILE__, __LINE__, __PRETTY_FUNCTION__,  \
                               format, ##args),                          \
index d467c0e829b3c32ca9f336326df2924e31c1f26d..5868d9aac5bad9583b94557f9af81db9ded8b2b9 100644 (file)
@@ -316,9 +316,9 @@ static inline Bool sr_EQ ( SysRes sr1, SysRes sr2 ) {
 #define VG_BUGS_TO "www.valgrind.org"
 
 /* Branch prediction hints. */
-#if 1 /*HAVE_BUILTIN_EXPECT*/
+#if defined(__GNUC__)
 #  define LIKELY(x)   __builtin_expect(!!(x), 1)
-#  define UNLIKELY(x) __builtin_expect((x), 0)
+#  define UNLIKELY(x) __builtin_expect(!!(x), 0)
 #else
 #  define LIKELY(x)   (x)
 #  define UNLIKELY(x) (x)
index af921128cefc1599412febac4f7d3edc7b7e8d5b..665ab0e18116bd78674cd08a735d537f0417b82d 100644 (file)
@@ -32,7 +32,7 @@
 #define __PUB_TOOL_LIBCBASSERT_H
 
 #define tl_assert(expr)                                                 \
-  ((void) ((expr) ? 0 :                                                 \
+  ((void) (LIKELY(expr) ? 0 :                                           \
            (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr,     \
                               (const Char*)__FILE__, __LINE__,          \
                               (const Char*)__PRETTY_FUNCTION__,         \
@@ -40,7 +40,7 @@
                               0)))
 
 #define tl_assert2(expr, format, args...)                               \
-  ((void) ((expr) ? 0 :                                                 \
+  ((void) (LIKELY(expr) ? 0 :                                           \
            (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr,     \
                               (const Char*)__FILE__, __LINE__,          \
                               (const Char*)__PRETTY_FUNCTION__,         \