diff options
author | marha <marha@users.sourceforge.net> | 2009-07-25 19:39:46 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-07-25 19:39:46 +0000 |
commit | 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 (patch) | |
tree | c1e02b9d3509aa97703aa4b540d4cd22ec4600ed /xorg-server/hw/xquartz/xpr/x-hash.h | |
parent | dc3c299dd0995549e2a6973ca0f25b254afd38a5 (diff) | |
download | vcxsrv-4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05.tar.gz vcxsrv-4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05.tar.bz2 vcxsrv-4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05.zip |
Added xorg-server-1.6.2.tar.gz
Diffstat (limited to 'xorg-server/hw/xquartz/xpr/x-hash.h')
-rw-r--r-- | xorg-server/hw/xquartz/xpr/x-hash.h | 31 |
1 files changed, 31 insertions, 0 deletions
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 <stdlib.h> +#include <assert.h> + 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 */ |