From: Søren Sandmann Pedersen <s...@redhat.com> While releasing 0.29.2 the distcheck run produced a number of error messages that had to be fixed in 349015e1fc5d912ba4253133b90e751d0b. These were not caught before so nobody had actually run pixman with debugging turned on. It's not the first time this has happened, see 5b0563f39eb29e4ae431717696174da5 for example.
So this patch makes the return_if_fail() macros use unlikely() around the expressions and then turns on error logging at all times. The performance hit should negligible since we were already evaluating the expressions. The place where DEBUG actually does cause a performance hit is in the region selfcheck code, and that will still only be enabled in development snapshots. --- pixman/pixman-private.h | 36 +++--------------------------------- pixman/pixman-utils.c | 4 ---- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index cb78a2e..181ab5c 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -1014,15 +1014,13 @@ float pixman_unorm_to_float (uint16_t u, int n_bits); #endif -#ifdef DEBUG - void _pixman_log_error (const char *function, const char *message); #define return_if_fail(expr) \ do \ { \ - if (!(expr)) \ + if (unlikely (!(expr))) \ { \ _pixman_log_error (FUNC, "The expression " # expr " was false"); \ return; \ @@ -1033,7 +1031,7 @@ _pixman_log_error (const char *function, const char *message); #define return_val_if_fail(expr, retval) \ do \ { \ - if (!(expr)) \ + if (unlikely (!(expr))) \ { \ _pixman_log_error (FUNC, "The expression " # expr " was false"); \ return (retval); \ @@ -1044,39 +1042,11 @@ _pixman_log_error (const char *function, const char *message); #define critical_if_fail(expr) \ do \ { \ - if (!(expr)) \ + if (unlikely (!(expr))) \ _pixman_log_error (FUNC, "The expression " # expr " was false"); \ } \ while (0) - -#else - -#define _pixman_log_error(f,m) do { } while (0) - -#define return_if_fail(expr) \ - do \ - { \ - if (!(expr)) \ - return; \ - } \ - while (0) - -#define return_val_if_fail(expr, retval) \ - do \ - { \ - if (!(expr)) \ - return (retval); \ - } \ - while (0) - -#define critical_if_fail(expr) \ - do \ - { \ - } \ - while (0) -#endif - /* * Matrix */ diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c index b1e9fb6..f31171f 100644 --- a/pixman/pixman-utils.c +++ b/pixman/pixman-utils.c @@ -292,8 +292,6 @@ _pixman_internal_only_get_implementation (void) return get_implementation (); } -#ifdef DEBUG - void _pixman_log_error (const char *function, const char *message) { @@ -310,5 +308,3 @@ _pixman_log_error (const char *function, const char *message) n_messages++; } } - -#endif -- 1.7.4 _______________________________________________ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman