mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
gdataset: use guintptr instead of gsize for pointer mangling
The previous code was in practice correct. (((guintptr) ptr) | ((gsize) mask)) works even if gsize is smaller than guintptr. And while the C standard only guarantees that cast between uintptr_t and void* works, on reasonable compilers it works to directly cast uintptr_t to GData*. Still, no need for such uncertainty. Just be clear about the involved types (use guintptr throughout) and cast first to (gpointer).
This commit is contained in:
parent
3f34a49ee9
commit
a426410919
@ -69,13 +69,13 @@
|
||||
|
||||
/* datalist pointer accesses have to be carried out atomically */
|
||||
#define G_DATALIST_GET_POINTER(datalist) \
|
||||
((GData*) ((guintptr) g_atomic_pointer_get (datalist) & ~(gsize) G_DATALIST_FLAGS_MASK_INTERNAL))
|
||||
((GData *) ((gpointer) ((guintptr) g_atomic_pointer_get (datalist) & ~((guintptr) G_DATALIST_FLAGS_MASK_INTERNAL))))
|
||||
|
||||
#define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \
|
||||
gpointer _oldv = g_atomic_pointer_get (datalist); \
|
||||
gpointer _newv; \
|
||||
do { \
|
||||
_newv = (gpointer) (((gsize) _oldv & G_DATALIST_FLAGS_MASK_INTERNAL) | (guintptr) pointer); \
|
||||
_newv = (gpointer) (((guintptr) _oldv & ((guintptr) G_DATALIST_FLAGS_MASK_INTERNAL)) | (guintptr) pointer); \
|
||||
} while (!g_atomic_pointer_compare_and_exchange_full ((void**) datalist, _oldv, \
|
||||
_newv, &_oldv)); \
|
||||
} G_STMT_END
|
||||
|
Loading…
Reference in New Issue
Block a user