From ec7a9d7281d7a595491e02ed450b71a1c8c73ad2 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sun, 14 Oct 2018 07:24:07 +0200 Subject: [PATCH] MayaType.h: fix pointer casting warnings warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] #define POINTER_TO_KEY(p) ((sizeof(void *) == sizeof(UINT)) ? (UINT)(p) : HashPtrToUINT(p)) ^ warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define UINT64_TO_POINTER(i) ((sizeof(void *) == sizeof(UINT64)) ? (void *)(i) : (void *)((UINT)(i))) ^ warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] #define POINTER_TO_UINT64(p) (((sizeof(void *) == sizeof(UINT64)) ? (UINT64)(p) : (UINT64)((UINT)(p)))) ^ --- src/Mayaqua/MayaType.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Mayaqua/MayaType.h b/src/Mayaqua/MayaType.h index 3223a726..4d134e2f 100644 --- a/src/Mayaqua/MayaType.h +++ b/src/Mayaqua/MayaType.h @@ -227,13 +227,28 @@ typedef int (COMPARE)(void *p1, void *p2); #define GET_ABS(a) ((a) >= 0 ? (a) : -(a)) // Convert the pointer to UINT -#define POINTER_TO_KEY(p) ((sizeof(void *) == sizeof(UINT)) ? (UINT)(p) : HashPtrToUINT(p)) +#ifdef CPU_64 +#define POINTER_TO_KEY(p) HashPtrToUINT(p) +#else +#define POINTER_TO_KEY(p) (UINT)(p) +#endif + // Compare the pointer and UINT #define COMPARE_POINTER_AND_KEY(p, i) (POINTER_TO_KEY(p) == (i)) + // Convert the pointer to UINT64 -#define POINTER_TO_UINT64(p) (((sizeof(void *) == sizeof(UINT64)) ? (UINT64)(p) : (UINT64)((UINT)(p)))) +#ifdef CPU_64 +#define POINTER_TO_UINT64(p) (UINT64)(p) +#else +#define POINTER_TO_UINT64(p) (UINT64)((UINT)(p)) +#endif + // Convert a UINT64 to pointer -#define UINT64_TO_POINTER(i) ((sizeof(void *) == sizeof(UINT64)) ? (void *)(i) : (void *)((UINT)(i))) +#ifdef CPU_64 +#define UINT64_TO_POINTER(i) (void *)(i) +#else +#define UINT64_TO_POINTER(i) (void *)((UINT)(i))) +#endif // Add the value #define UINT_ADD(i, j) ((i == INFINITE || i == 0x7fffffff) ? (i) : (i += j))