summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
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 'tools')
-rw-r--r--tools/bitmap_to_c.c7
-rw-r--r--tools/icon_to_c.c13
2 files changed, 6 insertions, 14 deletions
diff --git a/tools/bitmap_to_c.c b/tools/bitmap_to_c.c
index e9cd4db2..c4e1df10 100644
--- a/tools/bitmap_to_c.c
+++ b/tools/bitmap_to_c.c
@@ -24,12 +24,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
+#include <spice/macros.h>
-#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
-#define TRUE 1
-#define FALSE 0
-
#define TAB " "
#define ERROR(str) printf("%s: error: %s\n", prog_name, str); exit(-1);
@@ -143,7 +140,7 @@ static Pixmap *init_bitmap(size_t input_size, uint8_t *buf)
if (file_header->header.bpp == 32) {
stride = file_header->header.width * sizeof(uint32_t);
} else if (file_header->header.bpp == 24) {
- stride = ALIGN(file_header->header.width * 3, 4);
+ stride = SPICE_ALIGN(file_header->header.width * 3, 4);
} else {
ERROR("unsupported bpp");
return NULL;
diff --git a/tools/icon_to_c.c b/tools/icon_to_c.c
index 6fd96fd0..d58995c9 100644
--- a/tools/icon_to_c.c
+++ b/tools/icon_to_c.c
@@ -24,17 +24,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
-
-#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
-#define TRUE 1
-#define FALSE 0
+#include <spice/macros.h>
#define TAB " "
#define ERROR(str) printf("%s: error: %s\n", prog_name, str); exit(-1);
-#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
-
static char *prog_name = NULL;
static size_t read_input(const char *file_name, uint8_t** out_buf)
@@ -166,7 +161,7 @@ static Icon *init_icon(uint8_t *buf, size_t buf_size)
}
if (!bitmap->image_size) {
- bitmap->image_size = ALIGN(bitmap->bpp * bitmap->width, 32) / 8 * bitmap->height;
+ bitmap->image_size = SPICE_ALIGN(bitmap->bpp * bitmap->width, 32) / 8 * bitmap->height;
}
if (bitmap->compression || bitmap->horizontal_resolution || bitmap->vertical_resolution ||
@@ -179,7 +174,7 @@ static Icon *init_icon(uint8_t *buf, size_t buf_size)
}
int pixmap_size = bitmap->width * sizeof(uint32_t) * ico->height;
- int mask_size = ALIGN(bitmap->width, 8) / 8 * ico->height;
+ int mask_size = SPICE_ALIGN(bitmap->width, 8) / 8 * ico->height;
Icon* icon = malloc(sizeof(*icon) + pixmap_size + mask_size);
icon->width = ico->width;
icon->height = ico->height;
@@ -223,7 +218,7 @@ static int icon_to_c_struct(const Icon *icon, const char *dest_file, const char
}
uint32_t pixmap_stride = icon->width * sizeof(uint32_t);
uint32_t pixmap_size = pixmap_stride * icon->height;
- uint32_t mask_stride = ALIGN(icon->width, 8) / 8;
+ uint32_t mask_stride = SPICE_ALIGN(icon->width, 8) / 8;
uint32_t mask_size = mask_stride * icon->height;
fprintf(f, "static const struct {\n"
TAB "uint32_t width;\n"