Fix sgen gchandle truncating pointers on Windows x64
authorcmp <cmp@melee.org>
Wed, 7 Oct 2015 19:41:31 +0000 (20:41 +0100)
committercmp <cmp@melee.org>
Wed, 7 Oct 2015 19:41:31 +0000 (20:41 +0100)
On Windows x64 sizeof(unsigned long) == 4, so & ~3UL ends up truncating
the upper 32 bits of the pointer.

mono/sgen/gc-internal-agnostic.h

index e3c695119e40f7ac64972c2ae00b321802e3e7ab..6b8a1a3dda85bab21a230052341e579d1f390806 100644 (file)
 /* h indicates whether to hide or just tag.
  * (-!!h ^ p) is used instead of (h ? ~p : p) to avoid multiple mentions of p.
  */
-#define MONO_GC_HIDE_POINTER(p,t,h) ((gpointer)(((-(size_t)!!(h) ^ (size_t)(p)) & ~3UL) | ((t) & 3UL)))
-#define MONO_GC_REVEAL_POINTER(p,h) ((gpointer)((-(size_t)!!(h) ^ (size_t)(p)) & ~3UL))
+#define MONO_GC_HIDE_POINTER(p,t,h) ((gpointer)(((-(size_t)!!(h) ^ (size_t)(p)) & ~(size_t)3) | ((t) & (size_t)3)))
+#define MONO_GC_REVEAL_POINTER(p,h) ((gpointer)((-(size_t)!!(h) ^ (size_t)(p)) & ~(size_t)3))
 
-#define MONO_GC_POINTER_TAG(p) ((size_t)(p) & 3UL)
+#define MONO_GC_POINTER_TAG(p) ((size_t)(p) & (size_t)3)
 
 #define MONO_GC_HANDLE_OCCUPIED_MASK (1)
 #define MONO_GC_HANDLE_VALID_MASK (2)