From 1356751c499d853b57bbc1eda31a92f86975dd5c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 19 Sep 2023 16:05:38 +0800 Subject: [PATCH] glib: Make things more 64-bit safe We want to avoid compiler warning C4311 as far as possible as they can be indicators of crashes that occur on 64-bit builds but not 32-bit builds, as Windows is an LLP64 system, so incorporate changes from later GLib releases that are meant to remedy such issues. --- glib/glib/gmacros.h | 2 +- glib/glib/gthread-win32.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glib/glib/gmacros.h b/glib/glib/gmacros.h index f3f542b..a4def7a 100644 --- a/glib/glib/gmacros.h +++ b/glib/glib/gmacros.h @@ -260,7 +260,7 @@ * fields through their offsets. */ -#if defined(__GNUC__) && __GNUC__ >= 4 +#if (defined(__GNUC__) && __GNUC__ >= 4) || defined (_MSC_VER) # define G_STRUCT_OFFSET(struct_type, member) \ ((glong) offsetof (struct_type, member)) #else diff --git a/glib/glib/gthread-win32.c b/glib/glib/gthread-win32.c index c54f2bd..e3b0c12 100644 --- a/glib/glib/gthread-win32.c +++ b/glib/glib/gthread-win32.c @@ -337,12 +337,12 @@ static CRITICAL_SECTION g_private_lock; static DWORD g_private_get_impl (GPrivate *key) { - DWORD impl = (DWORD) key->p; + DWORD impl = (DWORD) GPOINTER_TO_UINT(key->p); if G_UNLIKELY (impl == 0) { EnterCriticalSection (&g_private_lock); - impl = (DWORD) key->p; + impl = (UINT_PTR) key->p; if (impl == 0) { GPrivateDestructor *destructor;