summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-03-09 11:10:00 +0100
committerAlexander Larsson <alexl@redhat.com>2010-03-09 11:10:00 +0100
commit90c5766caf16e35cb871116a4655a106a3c272dc (patch)
treeddc2ea976240a3f8f9c3294b41492256e6eb3f82 /common
parent5cb99e12c6817592f49ca153a3081dd6b5995cf2 (diff)
downloadspice-90c5766caf16e35cb871116a4655a106a3c272dc.tar.gz
spice-90c5766caf16e35cb871116a4655a106a3c272dc.tar.xz
spice-90c5766caf16e35cb871116a4655a106a3c272dc.zip
Use macros from <spice/macros.h> rather than duplicate them
Diffstat (limited to 'common')
-rw-r--r--common/canvas_base.c23
-rw-r--r--common/canvas_utils.c14
-rw-r--r--common/glc.c4
-rw-r--r--common/lines.c17
-rw-r--r--common/lz_config.h10
-rw-r--r--common/pixman_utils.c9
-rw-r--r--common/quic.c6
-rw-r--r--common/rect.h4
-rw-r--r--common/region.c7
9 files changed, 19 insertions, 75 deletions
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 01df479b..cbe37fe5 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -23,6 +23,7 @@
#include <math.h>
#include <spice/draw.h>
+#include <spice/macros.h>
#include "quic.h"
#include "lz.h"
#include "canvas_base.h"
@@ -71,18 +72,6 @@
#define DBG(level, format, ...) printf("%s: debug: " format "\n", __FUNCTION__, ## __VA_ARGS__);
#endif
-#ifndef ALIGN
-#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
-#endif
-
-#ifndef MIN
-#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
-#endif
-
-#ifndef MAX
-#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
-#endif
-
#define ROUND(_x) ((int)floor((_x) + 0.5))
#ifdef WIN32
@@ -1148,7 +1137,7 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b
src_stride = bitmap->stride;
end_line = src_line + (bitmap->y * src_stride);
access_test(canvas, src_line, end_line - src_line);
- line_size = ALIGN(bitmap->x, 8) >> 3;
+ line_size = SPICE_ALIGN(bitmap->x, 8) >> 3;
dest_stride = pixman_image_get_stride(surface);
dest_line = (uint8_t *)pixman_image_get_data(surface);
@@ -1243,7 +1232,7 @@ static inline pixman_image_t *canvas_A1_invers(pixman_image_t *src_surf)
uint8_t *src_line = (uint8_t *)pixman_image_get_data(src_surf);
int src_stride = pixman_image_get_stride(src_surf);
uint8_t *end_line = src_line + (height * src_stride);
- int line_size = ALIGN(width, 8) >> 3;
+ int line_size = SPICE_ALIGN(width, 8) >> 3;
uint8_t *dest_line = (uint8_t *)pixman_image_get_data(invers);
int dest_stride = pixman_image_get_stride(invers);
@@ -1382,7 +1371,7 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int
static inline SpiceRasterGlyph *canvas_next_raster_glyph(const SpiceRasterGlyph *glyph, int bpp)
{
return (SpiceRasterGlyph *)((uint8_t *)(glyph + 1) +
- (ALIGN(glyph->width * bpp, 8) * glyph->height >> 3));
+ (SPICE_ALIGN(glyph->width * bpp, 8) * glyph->height >> 3));
}
static inline void canvas_raster_glyph_box(const SpiceRasterGlyph *glyph, SpiceRect *r)
@@ -1472,7 +1461,7 @@ static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des
width = glyph_box.right - glyph_box.left;
switch (bpp) {
case 1: {
- int src_stride = ALIGN(width, 8) >> 3;
+ int src_stride = SPICE_ALIGN(width, 8) >> 3;
int i;
src += src_stride * (lines);
@@ -1485,7 +1474,7 @@ static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des
}
case 4: {
uint8_t *end;
- int src_stride = ALIGN(width * 4, 8) >> 3;
+ int src_stride = SPICE_ALIGN(width * 4, 8) >> 3;
src += src_stride * lines;
dest += glyph_box.left;
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 89ebe121..2ab8f0b6 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -18,6 +18,8 @@
#include "canvas_utils.h"
+#include <spice/macros.h>
+
#ifdef __GNUC__
#include <stdlib.h>
#include <stdio.h>
@@ -42,10 +44,6 @@ extern int gdi_handlers;
}
#endif
-#ifndef ALIGN
-#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
-#endif
-
static void release_data(pixman_image_t *image, void *release_data)
{
PixmanData *data = (PixmanData *)release_data;
@@ -154,11 +152,11 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
break;
case PIXMAN_a8:
bitmap_info.inf.bmiHeader.biBitCount = 8;
- nstride = ALIGN(width, 4);
+ nstride = SPICE_ALIGN(width, 4);
break;
case PIXMAN_a1:
bitmap_info.inf.bmiHeader.biBitCount = 1;
- nstride = ALIGN(width, 32) / 8;
+ nstride = SPICE_ALIGN(width, 32) / 8;
break;
default:
CANVAS_ERROR("invalid format");
@@ -208,10 +206,10 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
stride = width * 4;
break;
case PIXMAN_a8:
- stride = ALIGN(width, 4);
+ stride = SPICE_ALIGN(width, 4);
break;
case PIXMAN_a1:
- stride = ALIGN(width, 32) / 8;
+ stride = SPICE_ALIGN(width, 32) / 8;
break;
default:
CANVAS_ERROR("invalid format");
diff --git a/common/glc.c b/common/glc.c
index 090dc03a..770da320 100644
--- a/common/glc.c
+++ b/common/glc.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
+#include <spice/macros.h>
#include <GL/gl.h>
#include <GL/glu.h>
@@ -37,9 +38,6 @@
#include "glc.h"
#include "gl_utils.h"
-#define TRUE 1
-#define FALSE 0
-
#define ASSERT(x) if (!(x)) {printf("%s: assert failed %s\n", __FUNCTION__, #x); abort();}
#define WARN_ONCE(x) { \
diff --git a/common/lines.c b/common/lines.c
index e02f3d67..5c07744c 100644
--- a/common/lines.c
+++ b/common/lines.c
@@ -48,6 +48,7 @@ SOFTWARE.
#include <stdio.h>
+#include <spice/macros.h>
#ifdef _XOPEN_SOURCE
#include <math.h>
#else
@@ -57,22 +58,6 @@ SOFTWARE.
#endif
#include "lines.h"
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-
-#ifndef MIN
-# define MIN(a, b) ((a < b) ? a : b)
-#endif
-
-#ifndef MAX
-# define MAX(a, b) ((a > b) ? a : b)
-#endif
-
#define xalloc(i) malloc(i)
#define xrealloc(a,b) realloc(a,b)
#define xfree(i) free(i)
diff --git a/common/lz_config.h b/common/lz_config.h
index 4db6dc36..439f413c 100644
--- a/common/lz_config.h
+++ b/common/lz_config.h
@@ -22,15 +22,7 @@
#define __LZ_CONFIG_H
#include <spice/types.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
+#include <spice/macros.h>
#ifdef __GNUC__
diff --git a/common/pixman_utils.c b/common/pixman_utils.c
index 7aff30b4..05ac03d7 100644
--- a/common/pixman_utils.c
+++ b/common/pixman_utils.c
@@ -17,19 +17,12 @@
*/
#include "pixman_utils.h"
+#include <spice/macros.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-
#ifndef ASSERT
#define ASSERT(x) if (!(x)) { \
printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \
diff --git a/common/quic.c b/common/quic.c
index 507c4504..e9fef5b5 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -20,6 +20,7 @@
// http://sun.iinf.polsl.gliwice.pl/~rstaros/sfalic/index.html
#include "quic.h"
+#include <spice/macros.h>
//#define DEBUG
@@ -36,8 +37,6 @@
#define QUIC_VERSION_MINOR 1U
#define QUIC_VERSION ((QUIC_VERSION_MAJOR << 16) | (QUIC_VERSION_MAJOR & 0xffff))
-#define ABS(a) ((a) >= 0 ? (a) : -(a))
-
#ifdef DEBUG
#define ASSERT(usr, x) \
@@ -49,9 +48,6 @@
#endif
-#define FALSE 0
-#define TRUE 1
-
typedef uint8_t BYTE;
/* maximum number of codes in family */
diff --git a/common/rect.h b/common/rect.h
index 43e7f21a..1627be6a 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -20,9 +20,7 @@
#define _H_RECT
#include <spice/draw.h>
-
-#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
-#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
+#include <spice/macros.h>
static inline void rect_sect(SpiceRect* r, const SpiceRect* bounds)
{
diff --git a/common/region.c b/common/region.c
index 06b76d56..7edcb5a1 100644
--- a/common/region.c
+++ b/common/region.c
@@ -19,16 +19,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <spice/macros.h>
#include "region.h"
#include "rect.h"
-#define FALSE 0
-#define TRUE 1
-
-#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
-#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
-
#define ASSERT(x) if (!(x)) { \
printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \
abort(); \