pidgin: 8b25c4f4: Apparently our use of va_list arguments ...

deryni at pidgin.im deryni at pidgin.im
Wed Jan 7 09:05:55 EST 2009


-----------------------------------------------------------------
Revision: 8b25c4f4ddcd70f0b21bc6bef1867d6df8b25075
Ancestor: 867b899f8aaf7afeaad8911ddf39fe2bada11d2d
Author: deryni at pidgin.im
Date: 2009-01-06T06:29:44
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8b25c4f4ddcd70f0b21bc6bef1867d6df8b25075

Modified files:
        configure.ac libpurple/plugins/perl/perl-handlers.c

ChangeLog: 

Apparently our use of va_list arguments in the perl signal callbacks doesn't
work on x86_64 (and other architectures where a va_list is not a pointer but
an array).

Pull an autoconf macro from Glib svn to check whether va_lists are arrays and
switch how we use them on that.

I'm not at all sure this is a complete fix but it seems to fix the issue as
currently reported.

Fixes #7404

-------------- next part --------------
============================================================
--- configure.ac	0ab449c5283fcec9ca5402e051a19fd9b4523fd7
+++ configure.ac	48913119b0c17e750bffe9f6d60641f4f798a49b
@@ -2285,6 +2285,30 @@ fi
         AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if you have a tm_gmtoff member in struct tm])
 fi
 
+AC_CACHE_CHECK([whether va_lists can be copied by value], ac_cv_va_val_copy,[
+	AC_TRY_RUN([#include <stdarg.h>
+#include <stdlib.h>
+	void f (int i, ...) {
+	va_list args1, args2;
+	va_start (args1, i);
+	args2 = args1;
+	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+	  exit (1);
+	va_end (args1); va_end (args2);
+	}
+	int main() {
+	  f (0, 42);
+	  return 0;
+	}],
+	[ac_cv_va_val_copy=yes],
+	[ac_cv_va_val_copy=no],
+	[ac_cv_va_val_copy=yes])
+])
+
+if test "x$ac_cv_va_val_copy" = "xno"; then
+	AC_DEFINE(VA_COPY_AS_ARRAY, 1, ['va_lists' cannot be copied as values])
+fi
+
 dnl #######################################################################
 dnl # Check for check
 dnl #######################################################################
============================================================
--- libpurple/plugins/perl/perl-handlers.c	d9c95b2f090211be097164eafe8cac02cce0faf6
+++ libpurple/plugins/perl/perl-handlers.c	82a02f5307b626e623a5aa24d58521ee14efca47
@@ -289,14 +289,18 @@ perl_signal_cb(va_list args, void *data)
 	PUSHMARK(sp);
 
 	purple_signal_get_values(handler->instance, handler->signal,
-	                       &ret_value, &value_count, &values);
+	                         &ret_value, &value_count, &values);
 
 	sv_args   = g_new(SV *,    value_count);
 	copy_args = g_new(void **, value_count);
 
 	for (i = 0; i < value_count; i++) {
 		sv_args[i] = purple_perl_sv_from_vargs(values[i],
+#ifdef VA_COPY_AS_ARRAY
+		                                       args,
+#else
 		                                       (va_list*)&args,
+#endif
 		                                       &copy_args[i]);
 
 		XPUSHs(sv_args[i]);


More information about the Commits mailing list