[Pixman] [PATCH 4/4] Various remaining fixes needed for successful compilation with C++

Siarhei Siamashka siarhei.siamashka at gmail.com
Sat Dec 15 21:13:50 PST 2012


Mostly the missing type casts, wrong types, or mixup between enums and ints.
---
 pixman/pixman-access.c     |    2 +-
 pixman/pixman-bits-image.c |    4 ++--
 pixman/pixman-compiler.h   |    4 ++++
 pixman/pixman-general.c    |    8 ++++----
 pixman/pixman-glyph.c      |    4 ++--
 pixman/pixman-image.c      |    2 +-
 pixman/pixman-private.h    |   19 ++++++++++++-------
 pixman/pixman-region.c     |   18 +++++++++---------
 pixman/pixman-x86.c        |    7 ++++---
 pixman/pixman.c            |    2 +-
 10 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index b5c8e40..046d2f1 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -465,7 +465,7 @@ convert_and_store_pixel (bits_image_t *		image,
 					bits, offset, PIXMAN_ ## format); \
     }									\
 									\
-    static const void *const __dummy__ ## format
+    static const void *const __dummy__ ## format = 0
 
 MAKE_ACCESSORS(a8r8g8b8);
 MAKE_ACCESSORS(x8r8g8b8);
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 86d80c3..76b651c 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -40,7 +40,7 @@ static uint32_t *
 _pixman_image_get_scanline_generic_float (pixman_iter_t * iter,
 					  const uint32_t *mask)
 {
-    pixman_iter_get_scanline_t fetch_32 = iter->data;
+    pixman_iter_get_scanline_t fetch_32 = (pixman_iter_get_scanline_t)iter->data;
     uint32_t *buffer = iter->buffer;
 
     fetch_32 (iter, NULL);
@@ -1508,7 +1508,7 @@ _pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter)
 	    }
 	    else
 	    {
-		iter->data = info->get_scanline_32;
+		iter->data = (void *)info->get_scanline_32;
 		iter->get_scanline = info->get_scanline_float;
 	    }
 	    return;
diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h
index a978acc..2e45dea 100644
--- a/pixman/pixman-compiler.h
+++ b/pixman/pixman-compiler.h
@@ -56,6 +56,10 @@
 # define INT64_MAX              (9223372036854775807)
 #endif
 
+#ifndef SIZE_MAX
+# define SIZE_MAX               ((size_t)-1)
+#endif
+
 
 #ifndef M_PI
 # define M_PI			3.14159265358979323846
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 0bf91e4..4354fd2 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -129,7 +129,7 @@ general_composite_rect  (pixman_implementation_t *imp,
     }
     else
     {
-	narrow = 0;
+	narrow = (iter_flags_t)0;
 	Bpp = 16;
     }
 
@@ -154,7 +154,7 @@ general_composite_rect  (pixman_implementation_t *imp,
     }
     
     /* src iter */
-    src_iter_flags = narrow | op_flags[op].src;
+    src_iter_flags = (iter_flags_t)(narrow | op_flags[op].src);
 
     _pixman_implementation_src_iter_init (imp->toplevel, &src_iter, src_image,
 					  src_x, src_y, width, height,
@@ -178,12 +178,12 @@ general_composite_rect  (pixman_implementation_t *imp,
 
     _pixman_implementation_src_iter_init (
 	imp->toplevel, &mask_iter, mask_image, mask_x, mask_y, width, height,
-	mask_buffer, narrow | (component_alpha? 0 : ITER_IGNORE_RGB), info->mask_flags);
+	mask_buffer, (iter_flags_t)(narrow | (component_alpha? 0 : ITER_IGNORE_RGB)), info->mask_flags);
 
     /* dest iter */
     _pixman_implementation_dest_iter_init (
 	imp->toplevel, &dest_iter, dest_image, dest_x, dest_y, width, height,
-	dest_buffer, narrow | op_flags[op].dst, info->dest_flags);
+	dest_buffer, (iter_flags_t)(narrow | op_flags[op].dst), info->dest_flags);
 
     compose = _pixman_implementation_lookup_combiner (
 	imp->toplevel, op, component_alpha, narrow);
diff --git a/pixman/pixman-glyph.c b/pixman/pixman-glyph.c
index 15b3f1f..022ae6e 100644
--- a/pixman/pixman-glyph.c
+++ b/pixman/pixman-glyph.c
@@ -361,7 +361,7 @@ pixman_glyph_get_mask_format (pixman_glyph_cache_t *cache,
 
     for (i = 0; i < n_glyphs; ++i)
     {
-	const glyph_t *glyph = glyphs[i].glyph;
+	const glyph_t *glyph = (const glyph_t *)glyphs[i].glyph;
 	pixman_format_code_t glyph_format = glyph->image->bits.format;
 
 	if (PIXMAN_FORMAT_TYPE (glyph_format) == PIXMAN_TYPE_A)
@@ -508,7 +508,7 @@ add_glyphs (pixman_glyph_cache_t *cache,
     uint32_t glyph_flags = 0;
     pixman_composite_func_t func = NULL;
     pixman_implementation_t *implementation = NULL;
-    uint32_t dest_format;
+    pixman_format_code_t dest_format;
     uint32_t dest_flags;
     pixman_box32_t dest_box;
     pixman_composite_info_t info;
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 6f076d5..65041b4 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -888,7 +888,7 @@ pixman_image_get_format (pixman_image_t *image)
     if (image->type == BITS)
 	return image->bits.format;
 
-    return 0;
+    return PIXMAN_null;
 }
 
 uint32_t
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 38e8b6c..0cb813e 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -653,14 +653,14 @@ _pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask);
 /* These "formats" all have depth 0, so they
  * will never clash with any real ones
  */
-#define PIXMAN_null             PIXMAN_FORMAT (0, 0, 0, 0, 0, 0)
-#define PIXMAN_solid            PIXMAN_FORMAT (0, 1, 0, 0, 0, 0)
-#define PIXMAN_pixbuf		PIXMAN_FORMAT (0, 2, 0, 0, 0, 0)
-#define PIXMAN_rpixbuf		PIXMAN_FORMAT (0, 3, 0, 0, 0, 0)
-#define PIXMAN_unknown		PIXMAN_FORMAT (0, 4, 0, 0, 0, 0)
-#define PIXMAN_any		PIXMAN_FORMAT (0, 5, 0, 0, 0, 0)
+#define PIXMAN_null    ((pixman_format_code_t) PIXMAN_FORMAT (0, 0, 0, 0, 0, 0))
+#define PIXMAN_solid   ((pixman_format_code_t) PIXMAN_FORMAT (0, 1, 0, 0, 0, 0))
+#define PIXMAN_pixbuf  ((pixman_format_code_t) PIXMAN_FORMAT (0, 2, 0, 0, 0, 0))
+#define PIXMAN_rpixbuf ((pixman_format_code_t) PIXMAN_FORMAT (0, 3, 0, 0, 0, 0))
+#define PIXMAN_unknown ((pixman_format_code_t) PIXMAN_FORMAT (0, 4, 0, 0, 0, 0))
+#define PIXMAN_any     ((pixman_format_code_t) PIXMAN_FORMAT (0, 5, 0, 0, 0, 0))
 
-#define PIXMAN_OP_any		(PIXMAN_N_OPERATORS + 1)
+#define PIXMAN_OP_any  ((pixman_op_t)(PIXMAN_N_OPERATORS + 1))
 
 #define FAST_PATH_ID_TRANSFORM			(1 <<  0)
 #define FAST_PATH_NO_ALPHA_MAP			(1 <<  1)
@@ -770,9 +770,14 @@ get_implementation (void)
 /* This function is exported for the sake of the test suite and not part
  * of the ABI.
  */
+
+PIXMAN_BEGIN_DECLS
+
 PIXMAN_EXPORT pixman_implementation_t *
 _pixman_internal_only_get_implementation (void);
 
+PIXMAN_END_DECLS
+
 /* Memory allocation helpers */
 
 static inline void *
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 8955fe7..4ae74cf 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -202,7 +202,7 @@ PIXREGION_SZOF (size_t n)
     return size + sizeof(region_data_type_t);
 }
 
-static void *
+static region_data_type_t *
 alloc_data (size_t n)
 {
     size_t sz = PIXREGION_SZOF (n);
@@ -1564,17 +1564,17 @@ quick_sort_rects (
  *-----------------------------------------------------------------------
  */
 
+/* Descriptor for regions under construction  in Step 2. */
+typedef struct
+{
+    region_type_t reg;
+    int prev_band;
+    int cur_band;
+} region_info_t;
+
 static pixman_bool_t
 validate (region_type_t * badreg)
 {
-    /* Descriptor for regions under construction  in Step 2. */
-    typedef struct
-    {
-        region_type_t reg;
-        int prev_band;
-        int cur_band;
-    } region_info_t;
-
     region_info_t stack_regions[64];
 
     int numRects;                   /* Original numRects for badreg	    */
diff --git a/pixman/pixman-x86.c b/pixman/pixman-x86.c
index 57e4d1f..3a61fb4 100644
--- a/pixman/pixman-x86.c
+++ b/pixman/pixman-x86.c
@@ -33,14 +33,15 @@
  * it.
  */
 
-typedef enum
-{
+typedef int cpu_features_t;
+
+enum {
     X86_MMX			= (1 << 0),
     X86_MMX_EXTENSIONS		= (1 << 1),
     X86_SSE			= (1 << 2) | X86_MMX_EXTENSIONS,
     X86_SSE2			= (1 << 3),
     X86_CMOV			= (1 << 4)
-} cpu_features_t;
+};
 
 #ifdef HAVE_GETISAX
 
diff --git a/pixman/pixman.c b/pixman/pixman.c
index f4e96b1..fc942e6 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -149,7 +149,7 @@ optimize_operator (pixman_op_t     op,
     is_dest_opaque >>= OPAQUE_SHIFT - 1;
     is_source_opaque >>= OPAQUE_SHIFT;
 
-    return operator_table[op].opaque_info[is_dest_opaque | is_source_opaque];
+    return (pixman_op_t)operator_table[op].opaque_info[is_dest_opaque | is_source_opaque];
 }
 
 /*
-- 
1.7.8.6



More information about the Pixman mailing list