fix crash on PPC, bugzilla 749604

This commit is contained in:
Karsten Hopp 2011-12-02 18:19:21 +01:00
parent 2bdadbf05a
commit 008f98f538
2 changed files with 126 additions and 1 deletions

120
gjs-1.30.0-749604.patch Normal file
View File

@ -0,0 +1,120 @@
diff -up newer-but-still-old/gi/function.c.fix-ffi-on-big-endian newer-but-still-old/gi/function.c
--- newer-but-still-old/gi/function.c.fix-ffi-on-big-endian 2011-11-28 15:24:07.453082729 -0600
+++ newer-but-still-old/gi/function.c 2011-11-29 12:25:58.317567749 -0600
@@ -166,6 +166,8 @@ gjs_callback_closure(ffi_cif *cif,
int i, n_args, n_jsargs;
jsval *jsargs, rval;
GITypeInfo ret_type;
+ GITypeTag return_tag;
+ GArgument return_value;
gboolean success = FALSE;
trampoline = data;
@@ -215,10 +217,55 @@ gjs_callback_closure(ffi_cif *cif,
GJS_ARGUMENT_RETURN_VALUE,
FALSE,
TRUE,
- result)) {
+ &return_value)) {
goto out;
}
+ return_tag = g_type_info_get_tag(&ret_type);
+ switch (return_tag) {
+ case GI_TYPE_TAG_INT8:
+ *(ffi_sarg *) result = (gint8) return_value.v_int8;
+ case GI_TYPE_TAG_UINT8:
+ *(ffi_arg *) result = (guint8) return_value.v_uint8;
+ break;
+ case GI_TYPE_TAG_INT16:
+ *(ffi_sarg *) result = (gint16) return_value.v_int16;
+ break;
+ case GI_TYPE_TAG_UINT16:
+ *(ffi_arg *) result = (guint16) return_value.v_uint16;
+ break;
+ case GI_TYPE_TAG_INT32:
+ *(ffi_sarg *) result = (gint32) return_value.v_int32;
+ break;
+ case GI_TYPE_TAG_UINT32:
+ case GI_TYPE_TAG_BOOLEAN:
+ case GI_TYPE_TAG_UNICHAR:
+ *(ffi_arg *) result = (guint32) return_value.v_uint32;
+
+ break;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ GIBaseInfo* interface_info;
+ GIInfoType interface_type;
+
+ interface_info = g_type_info_get_interface(&ret_type);
+ interface_type = g_base_info_get_type(interface_info);
+
+ switch (interface_type) {
+ case GI_INFO_TYPE_ENUM:
+ case GI_INFO_TYPE_FLAGS:
+ *(ffi_sarg *) result = (gint32) return_value.v_long;
+ break;
+ default:
+ *(ffi_arg *) result = (ffi_arg) return_value.v_pointer;
+ break;
+ }
+ }
+ default:
+ *(ffi_arg *) result = (ffi_arg) return_value.v_pointer;
+ break;
+ }
+
success = TRUE;
out:
@@ -673,6 +720,50 @@ gjs_invoke_c_function(JSContext *co
g_assert_cmpuint(next_rval, <, function->js_out_argc);
+ switch (return_tag) {
+ case GI_TYPE_TAG_INT8:
+ return_value.v_int8 = (gint8) return_value.v_long;
+ case GI_TYPE_TAG_UINT8:
+ return_value.v_uint8 = (guint8) return_value.v_ulong;
+ break;
+ case GI_TYPE_TAG_INT16:
+ return_value.v_int16 = (gint16) return_value.v_long;
+ break;
+ case GI_TYPE_TAG_UINT16:
+ return_value.v_uint16 = (guint16) return_value.v_ulong;
+ break;
+ case GI_TYPE_TAG_INT32:
+ return_value.v_int32 = (gint32) return_value.v_long;
+ break;
+ case GI_TYPE_TAG_UINT32:
+ case GI_TYPE_TAG_BOOLEAN:
+ case GI_TYPE_TAG_UNICHAR:
+ return_value.v_uint32 = (guint32) return_value.v_ulong;
+
+ break;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ GIBaseInfo* interface_info;
+ GIInfoType interface_type;
+
+ interface_info = g_type_info_get_interface(&return_info);
+ interface_type = g_base_info_get_type(interface_info);
+
+
+ switch(interface_type) {
+ case GI_INFO_TYPE_ENUM:
+ case GI_INFO_TYPE_FLAGS:
+ return_value.v_int32 = (gint32) return_value.v_long;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
array_length_pos = g_type_info_get_array_length(&return_info);
if (array_length_pos >= 0) {
GIArgInfo array_length_arg;

View File

@ -1,6 +1,6 @@
Name: gjs Name: gjs
Version: 1.31.0 Version: 1.31.0
Release: 1%{?dist} Release: 2%{?dist}
Summary: Javascript Bindings for GNOME Summary: Javascript Bindings for GNOME
Group: System Environment/Libraries Group: System Environment/Libraries
@ -12,6 +12,7 @@ License: MIT and (MPLv1.1 or GPLv2+ or LGPLv2+)
URL: http://live.gnome.org/Gjs/ URL: http://live.gnome.org/Gjs/
#VCS: git://git.gnome.org/gjs #VCS: git://git.gnome.org/gjs
Source0: http://download.gnome.org/sources/%{name}/1.31/%{name}-%{version}.tar.xz Source0: http://download.gnome.org/sources/%{name}/1.31/%{name}-%{version}.tar.xz
Patch0: gjs-1.30.0-749604.patch
BuildRequires: js-devel BuildRequires: js-devel
BuildRequires: cairo-devel BuildRequires: cairo-devel
@ -39,6 +40,7 @@ Files for development with %{name}.
%prep %prep
%setup -q %setup -q
%patch0 -p1
rm -f configure rm -f configure
@ -80,6 +82,9 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%{_libdir}/*.so %{_libdir}/*.so
%changelog %changelog
* Fri Dec 02 2011 Karsten Hopp <karsten@redhat.com> 1.31.0-2
- fix crash on PPC, bugzilla 749604
* Wed Nov 2 2011 Matthias Clasen <mclasen@redhat.com> - 1.31.0-1 * Wed Nov 2 2011 Matthias Clasen <mclasen@redhat.com> - 1.31.0-1
- Update to 1.31.0 - Update to 1.31.0