• Dan Williams's avatar
    closure: fix handling of ENUMs and integral return types on 64-bit BE platforms · 8e82225a
    Dan Williams authored
    enums are stored in v_long but need to be marshalled as signed
    integers.  On platforms where int is 32 bits, taking the
    address of v_long resulted in the wrong 32 bits being marshalled.
    So we need to stuff the enum's int-sized value to a temporary
    int-sized variable and marshall that instead.
    
    Second, on return, libffi actually returns a pointer to a value
    that's sized according to platform conventions, not according to
    what the caller requested.  ie if ffi_type_sint was requested, the
    value can still be a 64-bit sign-extended long on a 64-bit
    architecture like PPC64, thus the caller cannot simply cast
    the return value as a pointer to the desired type, but must cast
    as a pointer to an integral type and then cast to the desired
    type to remove any sign extension complications.
    
    For more information on how to correctly handle libffi return
    values, see the following bug, specifically comment 35:
    
    https://bugzilla.redhat.com/show_bug.cgi?id=736489
    
    "For 64-bit ABIs that extend integral returns types to 64-bits, libffi always
    returns full 64-bit values that you can truncate in the calling code.   It's
    just the way it is has always been.  Please don't change libffi.  I'll document
    this clearly for the next version (perhaps there is a mention of this, I
    haven't looked yet).
    
    The same is true for returning 8-bit values, for instance, on 32-bit systems.
    All ABIs extend those results to the full 32-bits so you need to provide a
    properly aligned buffer that's big enough to hold the result."
    
    https://bugzilla.gnome.org/show_bug.cgi?id=659881
    8e82225a
Name
Last commit
Last update
..
tests Loading commit data...
.gitignore Loading commit data...
ChangeLog Loading commit data...
Makefile.am Loading commit data...
abicheck.sh Loading commit data...
gatomicarray.c Loading commit data...
gatomicarray.h Loading commit data...
gbinding.c Loading commit data...
gbinding.h Loading commit data...
gboxed.c Loading commit data...
gboxed.h Loading commit data...
gclosure.c Loading commit data...
gclosure.h Loading commit data...
genums.c Loading commit data...
genums.h Loading commit data...
glib-genmarshal.c Loading commit data...
glib-mkenums.in Loading commit data...
glib-types.h Loading commit data...
gmarshal.c Loading commit data...
gmarshal.h Loading commit data...
gmarshal.list Loading commit data...
gobject-query.c Loading commit data...
gobject.c Loading commit data...
gobject.h Loading commit data...
gobject.py Loading commit data...
gobject.rc.in Loading commit data...
gobject.stp.in Loading commit data...
gobject.symbols Loading commit data...
gobject_probes.d Loading commit data...
gobject_trace.h Loading commit data...
gobjectnotifyqueue.c Loading commit data...
gparam.c Loading commit data...
gparam.h Loading commit data...
gparamspecs.c Loading commit data...
gparamspecs.h Loading commit data...
gsignal.c Loading commit data...
gsignal.h Loading commit data...
gsourceclosure.c Loading commit data...
gsourceclosure.h Loading commit data...
gtype-private.h Loading commit data...
gtype.c Loading commit data...
gtype.h Loading commit data...
gtypemodule.c Loading commit data...
gtypemodule.h Loading commit data...
gtypeplugin.c Loading commit data...
gtypeplugin.h Loading commit data...
gvalue.c Loading commit data...
gvalue.h Loading commit data...
gvaluearray.c Loading commit data...
gvaluearray.h Loading commit data...
gvaluecollector.h Loading commit data...
gvaluetransform.c Loading commit data...
gvaluetypes.c Loading commit data...
gvaluetypes.h Loading commit data...
libgobject-gdb.py.in Loading commit data...
makefile.msc.in Loading commit data...
marshal-genstrings.pl Loading commit data...
testgobject.c Loading commit data...