|
From: <sv...@va...> - 2011-05-09 21:54:53
|
Author: sewardj
Date: 2011-05-09 22:54:44 +0100 (Mon, 09 May 2011)
New Revision: 11736
Log:
Tidying up of branch-predict hint macros LIKELY/UNLIKELY. Fixes
#271504. (Florian Krohm, br...@ac...)
Modified:
trunk/coregrind/pub_core_libcassert.h
trunk/include/pub_tool_basics.h
trunk/include/pub_tool_libcassert.h
Modified: trunk/coregrind/pub_core_libcassert.h
===================================================================
--- trunk/coregrind/pub_core_libcassert.h 2011-05-09 21:33:32 UTC (rev 11735)
+++ trunk/coregrind/pub_core_libcassert.h 2011-05-09 21:54:44 UTC (rev 11736)
@@ -47,14 +47,14 @@
"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), \
Modified: trunk/include/pub_tool_basics.h
===================================================================
--- trunk/include/pub_tool_basics.h 2011-05-09 21:33:32 UTC (rev 11735)
+++ trunk/include/pub_tool_basics.h 2011-05-09 21:54:44 UTC (rev 11736)
@@ -316,9 +316,9 @@
#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)
Modified: trunk/include/pub_tool_libcassert.h
===================================================================
--- trunk/include/pub_tool_libcassert.h 2011-05-09 21:33:32 UTC (rev 11735)
+++ trunk/include/pub_tool_libcassert.h 2011-05-09 21:54:44 UTC (rev 11736)
@@ -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__, \
|