Remove the (no longer effective) empty if-branch.

* glib/gmessages.h (g_assert):
	(g_return_if_fail):
	(g_return_val_if_fail): Remove the (no longer effective) empty
	if-branch.

	* glib/gmacros.h: Change the definition of G_LIKELY, so that
	g_return_if_fail() and friends still trigger a gcc warning if
	the expr is an assignment.
This commit is contained in:
Matthias Clasen
2002-11-25 21:34:16 +00:00
parent 129cfb8bf8
commit 827f3c4fa4
9 changed files with 97 additions and 8 deletions

View File

@@ -208,10 +208,22 @@
* The G_LIKELY and G_UNLIKELY macros let the programmer give hints to
* the compiler about the expected result of an expression. Some compilers
* can use this information for optimizations.
*
* The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
* putting assignments in g_return_if_fail ().
*/
#if defined(__GNUC__) && (__GNUC__ > 2)
#define G_LIKELY(expr) __builtin_expect (!!(expr), 1)
#define G_UNLIKELY(expr) __builtin_expect (!!(expr), 0)
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#define _G_BOOLEAN_EXPR(expr) \
__extension__ ({ \
int _g_boolean_var_; \
if (expr) \
_g_boolean_var_ = 1; \
else \
_g_boolean_var_ = 0; \
_g_boolean_var_; \
})
#define G_LIKELY(expr) __builtin_expect (_G_BOOLEAN_EXPR(expr), 1)
#define G_UNLIKELY(expr) __builtin_expect (_G_BOOLEAN_EXPR(expr), 0)
#else
#define G_LIKELY(expr) expr
#define G_UNLIKELY(expr) expr