GType <=> gpointer
- From: muppet <scott asofyet org>
- To: gtk-devel-list gnome org
- Subject: GType <=> gpointer
- Date: Tue, 3 Feb 2004 00:03:24 -0500
Here's a little something i stumbled across while debugging a really
bizarre gtk2-perl crash on alpha processors.
type = (GType) GPOINTER_TO_UINT
(g_hash_table_lookup (types_by_package, package));
that code results in an invalid GType on alpha. that's because:
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
and
sizeof (GType) == sizeof (gulong)
sizeof (guint) != sizeof (GType)
thus, the GPOINTER_TO_UINT filter has the effect of stripping the upper
4 bytes off of the GType value, resulting in an invalid GType which
later causes Very Bad Things to happen.
glib seems to jump through some hoops to ensure that a GType is the
same size as the platform's pointer (actually, the size of size_t on
that platform), but doesn't bother with the relationship to int/uint.
is it more correct to do
type = (GType) pointer
than to use the GPOINTER_TO_UINT macro? should there be a
GPOINTER_TO_GTYPE/GTYPE_TO_GPOINTER pair?
interestingly, the GPOINTER_TO_UINT casts were necessary to get
gtk2-perl working correctly on x86_64, and seem to have no ill effect
on mips.
this also seems to imply that a G_TYPE_UINT column in a TreeModel is
not sufficient to hold GTypes, nor would G_TYPE_ULONG always suffice.
--
muppet <scott at asofyet dot org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]