summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2021-07-25 06:18:37 +0930
committerAdrian Johnson <ajohnson@redneon.com>2021-07-25 11:01:20 +0930
commit9fbf42754899898934bc8bf4f8eeacba37656fdc (patch)
tree71290e364a7dd65973cb0cdcef32615c4c8dc374
parent099d71fb9f267153da8b45adc288f9715fbb4611 (diff)
downloadcairo-9fbf42754899898934bc8bf4f8eeacba37656fdc.tar.gz
Use uintptr_t for all casts between pointer and integer
On 64-bit windows, long is 32-bit. When compiling there are a large number of warnings about mismatched sizes when casting long to/from a pointer. Use the (u)intptr_t type for any integer that will have a pointer stored in it. Use a (u)intptr_t cast when integers are stored in pointers to silence warnings. Fixes #263
-rw-r--r--src/cairo-cache-private.h2
-rw-r--r--src/cairo-cache.c8
-rw-r--r--src/cairo-cogl-gradient.c6
-rw-r--r--src/cairo-cogl-surface.c8
-rw-r--r--src/cairo-ft-font.c6
-rw-r--r--src/cairo-gl-gradient.c6
-rw-r--r--src/cairo-image-compositor.c4
-rw-r--r--src/cairo-mempool.c6
-rw-r--r--src/cairo-path-fixed-private.h2
-rw-r--r--src/cairo-path-fixed.c4
-rw-r--r--src/cairo-pattern-private.h10
-rw-r--r--src/cairo-pattern.c32
-rw-r--r--src/cairo-scaled-font-subsets.c4
-rwxr-xr-xsrc/cairo-scaled-font.c10
-rw-r--r--src/cairo-script-surface.c10
-rw-r--r--src/cairo-toy-font-face.c6
-rw-r--r--src/cairo-types-private.h2
-rw-r--r--src/cairo-vg-surface.c6
-rw-r--r--src/cairoint.h6
-rw-r--r--src/drm/cairo-drm-intel.c2
-rw-r--r--src/win32/cairo-win32-font.c2
-rw-r--r--util/cairo-script/cairo-script-private.h2
-rw-r--r--util/cairo-trace/lookup-symbol.c2
-rw-r--r--util/cairo-trace/trace.c2
24 files changed, 74 insertions, 74 deletions
diff --git a/src/cairo-cache-private.h b/src/cairo-cache-private.h
index 24b6d0b20..03e2bbf31 100644
--- a/src/cairo-cache-private.h
+++ b/src/cairo-cache-private.h
@@ -84,7 +84,7 @@
* not be initialized if so desired.
**/
typedef struct _cairo_cache_entry {
- unsigned long hash;
+ uintptr_t hash;
unsigned long size;
} cairo_cache_entry_t;
diff --git a/src/cairo-cache.c b/src/cairo-cache.c
index 5c4e4caa3..96809b585 100644
--- a/src/cairo-cache.c
+++ b/src/cairo-cache.c
@@ -315,18 +315,18 @@ _cairo_cache_foreach (cairo_cache_t *cache,
closure);
}
-unsigned long
+uintptr_t
_cairo_hash_string (const char *c)
{
/* This is the djb2 hash. */
- unsigned long hash = _CAIRO_HASH_INIT_VALUE;
+ uintptr_t hash = _CAIRO_HASH_INIT_VALUE;
while (c && *c)
hash = ((hash << 5) + hash) + *c++;
return hash;
}
-unsigned long
-_cairo_hash_bytes (unsigned long hash,
+uintptr_t
+_cairo_hash_bytes (uintptr_t hash,
const void *ptr,
unsigned int length)
{
diff --git a/src/cairo-cogl-gradient.c b/src/cairo-cogl-gradient.c
index cdb4cae82..9fb5ce740 100644
--- a/src/cairo-cogl-gradient.c
+++ b/src/cairo-cogl-gradient.c
@@ -39,7 +39,7 @@
//#define DUMP_GRADIENTS_TO_PNG
-static unsigned long
+static uintptr_t
_cairo_cogl_linear_gradient_hash (unsigned int n_stops,
const cairo_gradient_stop_t *stops)
{
@@ -49,7 +49,7 @@ _cairo_cogl_linear_gradient_hash (unsigned int n_stops,
static cairo_cogl_linear_gradient_t *
_cairo_cogl_linear_gradient_lookup (cairo_cogl_device_t *ctx,
- unsigned long hash,
+ uintptr_t hash,
unsigned int n_stops,
const cairo_gradient_stop_t *stops)
{
@@ -359,7 +359,7 @@ _cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
const cairo_bool_t need_mirrored_gradient,
cairo_cogl_linear_gradient_t **gradient_out)
{
- unsigned long hash;
+ uintptr_t hash;
cairo_cogl_linear_gradient_t *gradient;
cairo_cogl_linear_texture_entry_t *entry;
cairo_gradient_stop_t *internal_stops;
diff --git a/src/cairo-cogl-surface.c b/src/cairo-cogl-surface.c
index 36e5f77d8..f4eee091c 100644
--- a/src/cairo-cogl-surface.c
+++ b/src/cairo-cogl-surface.c
@@ -700,7 +700,7 @@ _cairo_cogl_fill_to_primitive (cairo_cogl_surface_t *surface,
cairo_cogl_path_fill_meta_t *acquired_meta;
cairo_cogl_path_fill_meta_t *insert_meta = NULL;
cairo_cogl_device_t *dev = to_device (surface->base.device);
- unsigned long hash;
+ uintptr_t hash;
*primitive = NULL;
@@ -842,8 +842,8 @@ _cairo_cogl_path_stroke_meta_destroy (cairo_cogl_path_stroke_meta_t *meta)
_cairo_freelist_free (meta->freelist, meta);
}
-static unsigned long
-_cairo_cogl_stroke_style_hash (unsigned long hash,
+static uintptr_t
+_cairo_cogl_stroke_style_hash (uintptr_t hash,
const cairo_stroke_style_t *style)
{
unsigned int i;
@@ -874,7 +874,7 @@ _cairo_cogl_stroke_to_primitive (cairo_cogl_surface_t *surface,
cairo_cogl_path_stroke_meta_t *insert_meta = NULL;
cairo_matrix_t identity;
cairo_cogl_device_t *dev = to_device (surface->base.device);
- unsigned long hash;
+ uintptr_t hash;
*primitive = NULL;
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 1f5befec3..fca24b3cd 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -397,7 +397,7 @@ _cairo_ft_unscaled_font_init_key (cairo_ft_unscaled_font_t *key,
int id,
FT_Face face)
{
- unsigned long hash;
+ uintptr_t hash;
key->from_face = from_face;
key->filename = filename;
@@ -406,8 +406,8 @@ _cairo_ft_unscaled_font_init_key (cairo_ft_unscaled_font_t *key,
hash = _cairo_hash_string (filename);
/* the constants are just arbitrary primes */
- hash += ((unsigned long) id) * 1607;
- hash += ((unsigned long) face) * 2137;
+ hash += ((uintptr_t) id) * 1607;
+ hash += ((uintptr_t) face) * 2137;
key->base.hash_entry.hash = hash;
}
diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c
index 1bbd8dd0e..293d4e30e 100644
--- a/src/cairo-gl-gradient.c
+++ b/src/cairo-gl-gradient.c
@@ -188,7 +188,7 @@ _cairo_gl_gradient_render (const cairo_gl_context_t *ctx,
return CAIRO_STATUS_SUCCESS;
}
-static unsigned long
+static uintptr_t
_cairo_gl_gradient_hash (unsigned int n_stops,
const cairo_gradient_stop_t *stops)
{
@@ -199,7 +199,7 @@ _cairo_gl_gradient_hash (unsigned int n_stops,
static cairo_gl_gradient_t *
_cairo_gl_gradient_lookup (cairo_gl_context_t *ctx,
- unsigned long hash,
+ uintptr_t hash,
unsigned int n_stops,
const cairo_gradient_stop_t *stops)
{
@@ -230,7 +230,7 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx,
const cairo_gradient_stop_t *stops,
cairo_gl_gradient_t **gradient_out)
{
- unsigned long hash;
+ uintptr_t hash;
cairo_gl_gradient_t *gradient;
cairo_status_t status;
int tex_width;
diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
index 8bf3fd4b1..0ded5388e 100644
--- a/src/cairo-image-compositor.c
+++ b/src/cairo-image-compositor.c
@@ -898,7 +898,7 @@ composite_glyphs (void *_dst,
index = index | (xphase << 24) | (yphase << 26);
- glyph = pixman_glyph_cache_lookup (glyph_cache, info->font, (void *)index);
+ glyph = pixman_glyph_cache_lookup (glyph_cache, info->font, (void *)(uintptr_t)index);
if (!glyph) {
cairo_scaled_glyph_t *scaled_glyph;
cairo_image_surface_t *glyph_surface;
@@ -916,7 +916,7 @@ composite_glyphs (void *_dst,
goto out_thaw;
glyph_surface = scaled_glyph->surface;
- glyph = pixman_glyph_cache_insert (glyph_cache, info->font, (void *)index,
+ glyph = pixman_glyph_cache_insert (glyph_cache, info->font, (void *)(uintptr_t)index,
glyph_surface->base.device_transform.x0,
glyph_surface->base.device_transform.y0,
glyph_surface->pixman_image);
diff --git a/src/cairo-mempool.c b/src/cairo-mempool.c
index ce40ce521..6ba254690 100644
--- a/src/cairo-mempool.c
+++ b/src/cairo-mempool.c
@@ -284,19 +284,19 @@ _cairo_mempool_init (cairo_mempool_t *pool,
void *base, size_t bytes,
int min_bits, int num_sizes)
{
- unsigned long tmp;
+ uintptr_t tmp;
int num_blocks;
int i;
/* Align the start to an integral chunk */
- tmp = ((unsigned long) base) & ((1 << min_bits) - 1);
+ tmp = ((uintptr_t) base) & ((1 << min_bits) - 1);
if (tmp) {
tmp = (1 << min_bits) - tmp;
base = (char *)base + tmp;
bytes -= tmp;
}
- assert ((((unsigned long) base) & ((1 << min_bits) - 1)) == 0);
+ assert ((((uintptr_t) base) & ((1 << min_bits) - 1)) == 0);
assert (num_sizes < ARRAY_LENGTH (pool->free));
pool->base = base;
diff --git a/src/cairo-path-fixed-private.h b/src/cairo-path-fixed-private.h
index cf7cd0836..e49906344 100644
--- a/src/cairo-path-fixed-private.h
+++ b/src/cairo-path-fixed-private.h
@@ -126,7 +126,7 @@ _cairo_path_fixed_append (cairo_path_fixed_t *path,
cairo_fixed_t tx,
cairo_fixed_t ty);
-cairo_private unsigned long
+cairo_private uintptr_t
_cairo_path_fixed_hash (const cairo_path_fixed_t *path);
cairo_private unsigned long
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index d74182346..a6ab4e389 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -172,10 +172,10 @@ _cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
return CAIRO_STATUS_SUCCESS;
}
-unsigned long
+uintptr_t
_cairo_path_fixed_hash (const cairo_path_fixed_t *path)
{
- unsigned long hash = _CAIRO_HASH_INIT_VALUE;
+ uintptr_t hash = _CAIRO_HASH_INIT_VALUE;
const cairo_path_buf_t *buf;
unsigned int count;
diff --git a/src/cairo-pattern-private.h b/src/cairo-pattern-private.h
index 26d584e68..f03dedd9e 100644
--- a/src/cairo-pattern-private.h
+++ b/src/cairo-pattern-private.h
@@ -308,15 +308,15 @@ cairo_private cairo_int_status_t
_cairo_pattern_get_ink_extents (const cairo_pattern_t *pattern,
cairo_rectangle_int_t *extents);
-cairo_private unsigned long
+cairo_private uintptr_t
_cairo_pattern_hash (const cairo_pattern_t *pattern);
-cairo_private unsigned long
-_cairo_linear_pattern_hash (unsigned long hash,
+cairo_private uintptr_t
+_cairo_linear_pattern_hash (uintptr_t hash,
const cairo_linear_pattern_t *linear);
-cairo_private unsigned long
-_cairo_radial_pattern_hash (unsigned long hash,
+cairo_private uintptr_t
+_cairo_radial_pattern_hash (uintptr_t hash,
const cairo_radial_pattern_t *radial);
cairo_private cairo_bool_t
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 32811af59..e7af5ff5e 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -3863,8 +3863,8 @@ _cairo_pattern_get_ink_extents (const cairo_pattern_t *pattern,
return CAIRO_STATUS_SUCCESS;
}
-static unsigned long
-_cairo_solid_pattern_hash (unsigned long hash,
+static uintptr_t
+_cairo_solid_pattern_hash (uintptr_t hash,
const cairo_solid_pattern_t *solid)
{
hash = _cairo_hash_bytes (hash, &solid->color, sizeof (solid->color));
@@ -3872,8 +3872,8 @@ _cairo_solid_pattern_hash (unsigned long hash,
return hash;
}
-static unsigned long
-_cairo_gradient_color_stops_hash (unsigned long hash,
+static uintptr_t
+_cairo_gradient_color_stops_hash (uintptr_t hash,
const cairo_gradient_pattern_t *gradient)
{
unsigned int n;
@@ -3894,8 +3894,8 @@ _cairo_gradient_color_stops_hash (unsigned long hash,
return hash;
}
-unsigned long
-_cairo_linear_pattern_hash (unsigned long hash,
+uintptr_t
+_cairo_linear_pattern_hash (uintptr_t hash,
const cairo_linear_pattern_t *linear)
{
hash = _cairo_hash_bytes (hash, &linear->pd1, sizeof (linear->pd1));
@@ -3904,8 +3904,8 @@ _cairo_linear_pattern_hash (unsigned long hash,
return _cairo_gradient_color_stops_hash (hash, &linear->base);
}
-unsigned long
-_cairo_radial_pattern_hash (unsigned long hash,
+uintptr_t
+_cairo_radial_pattern_hash (uintptr_t hash,
const cairo_radial_pattern_t *radial)
{
hash = _cairo_hash_bytes (hash, &radial->cd1.center, sizeof (radial->cd1.center));
@@ -3916,8 +3916,8 @@ _cairo_radial_pattern_hash (unsigned long hash,
return _cairo_gradient_color_stops_hash (hash, &radial->base);
}
-static unsigned long
-_cairo_mesh_pattern_hash (unsigned long hash, const cairo_mesh_pattern_t *mesh)
+static uintptr_t
+_cairo_mesh_pattern_hash (uintptr_t hash, const cairo_mesh_pattern_t *mesh)
{
const cairo_mesh_patch_t *patch = _cairo_array_index_const (&mesh->patches, 0);
unsigned int i, n = _cairo_array_num_elements (&mesh->patches);
@@ -3928,8 +3928,8 @@ _cairo_mesh_pattern_hash (unsigned long hash, const cairo_mesh_pattern_t *mesh)
return hash;
}
-static unsigned long
-_cairo_surface_pattern_hash (unsigned long hash,
+static uintptr_t
+_cairo_surface_pattern_hash (uintptr_t hash,
const cairo_surface_pattern_t *surface)
{
hash ^= surface->surface->unique_id;
@@ -3937,8 +3937,8 @@ _cairo_surface_pattern_hash (unsigned long hash,
return hash;
}
-static unsigned long
-_cairo_raster_source_pattern_hash (unsigned long hash,
+static uintptr_t
+_cairo_raster_source_pattern_hash (uintptr_t hash,
const cairo_raster_source_pattern_t *raster)
{
hash ^= (uintptr_t)raster->user_data;
@@ -3946,10 +3946,10 @@ _cairo_raster_source_pattern_hash (unsigned long hash,
return hash;
}
-unsigned long
+uintptr_t
_cairo_pattern_hash (const cairo_pattern_t *pattern)
{
- unsigned long hash = _CAIRO_HASH_INIT_VALUE;
+ uintptr_t hash = _CAIRO_HASH_INIT_VALUE;
if (pattern->status)
return 0;
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 1f0e53577..0ae41aebe 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -255,12 +255,12 @@ _cairo_sub_font_init_key (cairo_sub_font_t *sub_font,
{
if (sub_font->is_scaled)
{
- sub_font->base.hash = (unsigned long) scaled_font;
+ sub_font->base.hash = (uintptr_t) scaled_font;
sub_font->scaled_font = scaled_font;
}
else
{
- sub_font->base.hash = (unsigned long) scaled_font->font_face;
+ sub_font->base.hash = (uintptr_t) scaled_font->font_face;
sub_font->scaled_font = scaled_font;
}
}
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 4f979c5db..9a6270df3 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -56,7 +56,7 @@
* size and transformation and a certain set of font options.
**/
-static uint32_t
+static uintptr_t
_cairo_scaled_font_compute_hash (cairo_scaled_font_t *scaled_font);
/* Global Glyph Cache
@@ -626,17 +626,17 @@ _hash_mix_bits (uint32_t hash)
return hash;
}
-static uint32_t
+static uintptr_t
_cairo_scaled_font_compute_hash (cairo_scaled_font_t *scaled_font)
{
- uint32_t hash = FNV1_32_INIT;
+ uintptr_t hash = FNV1_32_INIT;
/* We do a bytewise hash on the font matrices */
hash = _hash_matrix_fnv (&scaled_font->font_matrix, hash);
hash = _hash_matrix_fnv (&scaled_font->ctm, hash);
hash = _hash_mix_bits (hash);
- hash ^= (unsigned long) scaled_font->original_font_face;
+ hash ^= (uintptr_t) scaled_font->original_font_face;
hash ^= cairo_font_options_hash (&scaled_font->options);
/* final mixing of bits */
@@ -2879,7 +2879,7 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
if (unlikely (page == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- page->cache_entry.hash = (unsigned long) scaled_font;
+ page->cache_entry.hash = (uintptr_t) scaled_font;
page->scaled_font = scaled_font;
page->cache_entry.size = 1; /* XXX occupancy weighting? */
page->num_glyphs = 0;
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 4d7778b99..800db0780 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -3047,7 +3047,7 @@ _emit_scaled_glyph_vector (cairo_script_surface_t *surface,
index = ++font_private->subset_glyph_index;
scaled_glyph->dev_private_key = ctx;
- scaled_glyph->dev_private = (void *) index;
+ scaled_glyph->dev_private = (void *)(uintptr_t)index;
_cairo_output_stream_printf (ctx->stream,
"%lu <<\n"
@@ -3095,7 +3095,7 @@ _emit_scaled_glyph_bitmap (cairo_script_surface_t *surface,
index = ++font_private->subset_glyph_index;
scaled_glyph->dev_private_key = ctx;
- scaled_glyph->dev_private = (void *) index;
+ scaled_glyph->dev_private = (void *)(uintptr_t)index;
_cairo_output_stream_printf (ctx->stream,
"%lu <<\n"
@@ -3395,7 +3395,7 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
goto BAIL;
}
- if ((long unsigned) scaled_glyph->dev_private > 256)
+ if ((uintptr_t)scaled_glyph->dev_private > 256)
break;
}
}
@@ -3466,7 +3466,7 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
if (font_private->has_sfnt)
c = glyphs[n].index;
else
- c = (uint8_t) (long unsigned) scaled_glyph->dev_private;
+ c = (uint8_t) (uintptr_t) scaled_glyph->dev_private;
_cairo_output_stream_write (base85_stream, &c, 1);
} else {
@@ -3475,7 +3475,7 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
glyphs[n].index);
else
_cairo_output_stream_printf (ctx->stream, " %lu",
- (long unsigned) scaled_glyph->dev_private);
+ (long unsigned) (uintptr_t)scaled_glyph->dev_private);
}
dx = scaled_glyph->metrics.x_advance;
diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index f51dab5ab..ef7122609 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -135,7 +135,7 @@ _cairo_toy_font_face_init_key (cairo_toy_font_face_t *key,
cairo_font_slant_t slant,
cairo_font_weight_t weight)
{
- unsigned long hash;
+ uintptr_t hash;
key->family = family;
key->owns_family = FALSE;
@@ -145,8 +145,8 @@ _cairo_toy_font_face_init_key (cairo_toy_font_face_t *key,
/* 1607 and 1451 are just a couple of arbitrary primes. */
hash = _cairo_hash_string (family);
- hash += ((unsigned long) slant) * 1607;
- hash += ((unsigned long) weight) * 1451;
+ hash += ((uintptr_t) slant) * 1607;
+ hash += ((uintptr_t) weight) * 1451;
key->base.hash_entry.hash = hash;
}
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index da373030c..0f46214ed 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -147,7 +147,7 @@ struct _cairo_observer {
* the entry need not be initialized if so desired.
**/
struct _cairo_hash_entry {
- unsigned long hash;
+ uintptr_t hash;
};
struct _cairo_array {
diff --git a/src/cairo-vg-surface.c b/src/cairo-vg-surface.c
index cbff748fe..6e1f11e2d 100644
--- a/src/cairo-vg-surface.c
+++ b/src/cairo-vg-surface.c
@@ -67,7 +67,7 @@ struct _cairo_vg_context {
cairo_status_t status;
cairo_reference_count_t ref_count;
- unsigned long target_id;
+ uintptr_t target_id;
VGPaint paint;
cairo_vg_surface_t *source;
@@ -100,7 +100,7 @@ struct _cairo_vg_surface {
cairo_surface_clipper_t clipper;
- unsigned long target_id;
+ uintptr_t target_id;
};
static const cairo_surface_backend_t cairo_vg_surface_backend;
@@ -1782,7 +1782,7 @@ egl_create_target (cairo_vg_context_t *context,
(EGLClientBuffer) surface->image,
config,
NULL);
- surface->target_id = (unsigned long) egl_surface;
+ surface->target_id = (uintptr_t) egl_surface;
return CAIRO_STATUS_SUCCESS;
}
diff --git a/src/cairoint.h b/src/cairoint.h
index 4dbb7f917..64ed2aa4d 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -424,11 +424,11 @@ _cairo_user_data_array_foreach (cairo_user_data_array_t *array,
#define _CAIRO_HASH_INIT_VALUE 5381
-cairo_private unsigned long
+cairo_private uintptr_t
_cairo_hash_string (const char *c);
-cairo_private unsigned long
-_cairo_hash_bytes (unsigned long hash,
+cairo_private uintptr_t
+_cairo_hash_bytes (uintptr_t hash,
const void *bytes,
unsigned int length);
diff --git a/src/drm/cairo-drm-intel.c b/src/drm/cairo-drm-intel.c
index e6fb83dd5..e45f999ec 100644
--- a/src/drm/cairo-drm-intel.c
+++ b/src/drm/cairo-drm-intel.c
@@ -1126,7 +1126,7 @@ intel_snapshot_cache_insert (intel_device_t *device,
if (device->snapshot_cache.freeze_count == 0)
_cairo_cache_freeze (&device->snapshot_cache);
- surface->snapshot_cache_entry.hash = (unsigned long) surface;
+ surface->snapshot_cache_entry.hash = (uintptr_t) surface;
status = _cairo_cache_insert (&device->snapshot_cache,
&surface->snapshot_cache_entry);
if (unlikely (status)) {
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index d0bb09e1a..792e329d4 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -1960,7 +1960,7 @@ _cairo_win32_font_face_init_key (cairo_win32_font_face_t *key,
LOGFONTW *logfont,
HFONT font)
{
- unsigned long hash = _CAIRO_HASH_INIT_VALUE;
+ uintptr_t hash = _CAIRO_HASH_INIT_VALUE;
key->logfont = *logfont;
key->hfont = font;
diff --git a/util/cairo-script/cairo-script-private.h b/util/cairo-script/cairo-script-private.h
index 7ae8be925..b1b4aed0e 100644
--- a/util/cairo-script/cairo-script-private.h
+++ b/util/cairo-script/cairo-script-private.h
@@ -284,7 +284,7 @@ typedef cairo_bool_t csi_boolean_t;
typedef csi_status_t (*csi_operator_t) (csi_t *);
typedef float csi_real_t;
typedef long csi_integer_t;
-typedef long csi_name_t;
+typedef intptr_t csi_name_t;
typedef struct _csi_array csi_array_t;
typedef struct _csi_buffer csi_buffer_t;
typedef struct _csi_compound_object csi_compound_object_t;
diff --git a/util/cairo-trace/lookup-symbol.c b/util/cairo-trace/lookup-symbol.c
index 4bc1fac1a..3934066b9 100644
--- a/util/cairo-trace/lookup-symbol.c
+++ b/util/cairo-trace/lookup-symbol.c
@@ -262,7 +262,7 @@ lookup_symbol (char *buf, int buflen, const void *ptr)
int bucket;
int len;
- bucket = (unsigned long) ptr % (sizeof (symbol_cache_hash) / sizeof (symbol_cache_hash[0]));
+ bucket = (uintptr_t) ptr % (sizeof (symbol_cache_hash) / sizeof (symbol_cache_hash[0]));
pthread_mutex_lock (&symbol_cache_mutex);
for (cache = symbol_cache_hash[bucket];
cache != NULL;
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index babcc06fa..cc4b18c0d 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -134,7 +134,7 @@ static void *_dlhandle = RTLD_NEXT;
#else
#error Unexpected pointer size
#endif
-#define BUCKET(b, ptr) (((unsigned long) (ptr) >> PTR_SHIFT) % ARRAY_LENGTH (b))
+#define BUCKET(b, ptr) (((uintptr_t) (ptr) >> PTR_SHIFT) % ARRAY_LENGTH (b))
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#define _BOOLEAN_EXPR(expr) \