From fdb25d97477635dafb0f8c328de65727a2d73a48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Sun, 21 Jun 2009 21:36:43 -0400 Subject: [PATCH] Move macros around in pixman-private.h --- pixman/pixman-private.h | 51 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 6f24c5e..78959a7 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -11,7 +11,9 @@ #include "pixman-compiler.h" - +/* + * Various useful macros + */ #ifndef FALSE #define FALSE 0 #endif @@ -20,14 +22,35 @@ #define TRUE 1 #endif +/* Integer division that rounds towards -infinity */ +#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \ + ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) + +/* Modulus that produces the remainder wrt. DIV */ +#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) + +#define CLIP(a,b,c) ((a) < (b) ? (b) : ((a) > (c) ? (c) : (a))) + +#ifndef MIN +# define MIN(a,b) ((a < b)? a : b) +#endif + +#ifndef MAX +# define MAX(a,b) ((a > b)? a : b) +#endif + #undef DEBUG #define DEBUG 0 +/* + * Utilities + */ + /* Memory allocation helpers */ -void *pixman_malloc_ab (unsigned int n, unsigned int b); -void *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c); -pixman_bool_t pixman_multiply_overflows_int (unsigned int a, unsigned int b); -pixman_bool_t pixman_addition_overflows_int (unsigned int a, unsigned int b); +void *pixman_malloc_ab (unsigned int n, unsigned int b); +void *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c); +pixman_bool_t pixman_multiply_overflows_int (unsigned int a, unsigned int b); +pixman_bool_t pixman_addition_overflows_int (unsigned int a, unsigned int b); #if DEBUG @@ -73,6 +96,8 @@ pixman_bool_t pixman_addition_overflows_int (unsigned int a, unsigned int b); #endif + + typedef struct image_common image_common_t; typedef struct source_image source_image_t; typedef struct solid_fill solid_fill_t; @@ -410,22 +435,6 @@ _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, #define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8) #define div_65535(x) (((x) + 0x8000 + (((x) + 0x8000) >> 16)) >> 16) -#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) - -/* Divides two fixed-point numbers and returns an integer */ -#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \ - ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) - -#define CLIP(a,b,c) ((a) < (b) ? (b) : ((a) > (c) ? (c) : (a))) - -#ifndef MIN -# define MIN(a,b) ((a < b)? a : b) -#endif - -#ifndef MAX -# define MAX(a,b) ((a > b)? a : b) -#endif - #ifdef PIXMAN_FB_ACCESSORS #define ACCESS(sym) sym##_accessors -- 2.7.4