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.
This commit is contained in:
Chun-wei Fan 2023-09-19 16:05:38 +08:00
parent 6e837c5436
commit 1356751c49
2 changed files with 3 additions and 3 deletions

View file

@ -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

View file

@ -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;