diff options
author | Søren Sandmann Pedersen <sandmann@redhat.com> | 2009-11-07 21:14:17 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-03-14 12:59:37 -0400 |
commit | da2ecbed6cc82fafc8c7c702d56b4cd3d1b9f5a7 (patch) | |
tree | 628d2b4f7039cda9c0f224be8a5d7c59ef6adca4 | |
parent | ff30a5cbb941a9559082c6a6052ef761c7de949c (diff) |
Add likely/unlikely macros to pixman-compiler.h
Use them in pixman.c to mark workarounds as unlikely.
-rw-r--r-- | pixman/pixman-compiler.h | 9 | ||||
-rw-r--r-- | pixman/pixman.c | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h index caafd0f8..35ef6861 100644 --- a/pixman/pixman-compiler.h +++ b/pixman/pixman-compiler.h @@ -78,3 +78,12 @@ # warning "unknown compiler" # define THREAD_LOCAL __thread #endif + +/* Likely / unlikely */ +#if defined (__GNUC__) && (__GNUC__ > 2) +# define likely(expr) (__builtin_expect (expr, 1)) +# define unlikely(expr) (__builtin_expect (expr, 0)) +#else +# define likely(expr) (expr) +# define unlikely(expr) (expr) +#endif diff --git a/pixman/pixman.c b/pixman/pixman.c index c71617e2..10e25d81 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -563,7 +563,7 @@ do_composite (pixman_implementation_t *imp, /* Check for workaround */ need_workaround = (src_flags | mask_flags | dest_flags) & FAST_PATH_NEEDS_WORKAROUND; - if (need_workaround) + if (unlikely (need_workaround)) { apply_workaround (src, &src_x, &src_y, &src_bits, &src_dx, &src_dy); apply_workaround (mask, &mask_x, &mask_y, &mask_bits, &mask_dx, &mask_dy); @@ -690,7 +690,7 @@ found: } out: - if (need_workaround) + if (unlikely (need_workaround)) { unapply_workaround (src, src_bits, src_dx, src_dy); unapply_workaround (mask, mask_bits, mask_dx, mask_dy); |