mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user