gbitlock: don't assume sizeof(gsize) == sizeof(gpointer)

Use a gpointer* instead of a gsize* as the g_atomic_pointer_* argument.
This is required for architectures such as Arm Morello where gsize is
64 bits but gpointer is 128 bits.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
This commit is contained in:
Alex Richardson 2022-12-14 23:55:18 +00:00
parent f7d2a58be6
commit 877c575cd9

View File

@ -424,7 +424,7 @@ void
contended:
{
gsize *pointer_address = address_nonvolatile;
gpointer *pointer_address = address_nonvolatile;
gsize mask = 1u << lock_bit;
gsize v;
@ -440,9 +440,9 @@ void
}
goto retry;
#else
gsize *pointer_address = address_nonvolatile;
gpointer *pointer_address = address_nonvolatile;
gsize mask = 1u << lock_bit;
gsize v;
guintptr v;
retry:
v = g_atomic_pointer_or (pointer_address, mask);
@ -499,15 +499,15 @@ gboolean
return result;
#else
void *address_nonvolatile = (void *) address;
gsize *pointer_address = address_nonvolatile;
gpointer *pointer_address = address_nonvolatile;
gsize mask = 1u << lock_bit;
gsize v;
guintptr v;
g_return_val_if_fail (lock_bit < 32, FALSE);
v = g_atomic_pointer_or (pointer_address, mask);
return ~v & mask;
return (~(gsize) v & mask) != 0;
#endif
}
}
@ -543,7 +543,7 @@ void
: "r" (address), "r" ((gsize) lock_bit)
: "cc", "memory");
#else
gsize *pointer_address = address_nonvolatile;
gpointer *pointer_address = address_nonvolatile;
gsize mask = 1u << lock_bit;
g_atomic_pointer_and (pointer_address, ~mask);