From 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 Mon Sep 17 00:00:00 2001 From: marha Date: Sat, 25 Jul 2009 19:39:46 +0000 Subject: Added xorg-server-1.6.2.tar.gz --- xorg-server/hw/xquartz/xpr/x-hash.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'xorg-server/hw/xquartz/xpr/x-hash.h') diff --git a/xorg-server/hw/xquartz/xpr/x-hash.h b/xorg-server/hw/xquartz/xpr/x-hash.h index 3456dbedf..78bc7b317 100644 --- a/xorg-server/hw/xquartz/xpr/x-hash.h +++ b/xorg-server/hw/xquartz/xpr/x-hash.h @@ -30,6 +30,9 @@ #ifndef X_HASH_H #define X_HASH_H 1 +#include +#include + typedef struct x_hash_table_struct x_hash_table; typedef int (x_compare_fun) (const void *a, const void *b); @@ -57,4 +60,32 @@ X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h, x_hash_foreach_fun *fun, void *data); +/* Conversion between unsigned int (e.g. xp_resource_id) and void pointer */ + +/* Forward declarations */ +static __inline__ void * +X_PFX (cvt_uint_to_vptr) (unsigned int val) __attribute__((always_inline)); +static __inline__ unsigned int +X_PFX (cvt_vptr_to_uint) (void * val) __attribute__((always_inline)); + +/* Implementations */ +static __inline__ void * +X_PFX (cvt_uint_to_vptr) (unsigned int val) +{ + return (void*)((size_t)(val)); +} + +static __inline__ unsigned int +X_PFX (cvt_vptr_to_uint) (void * val) +{ + size_t sv = (size_t)val; + unsigned int uv = (unsigned int)sv; + + /* If this assert fails, chances are val actually is a pointer, + or there's been memory corruption */ + assert(sv == uv); + + return uv; +} + #endif /* X_HASH_H */ -- cgit v1.2.3