changeset 25263:b9f7a8ca1369

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
author Etan Reisner <pidgin@unreliablesource.net>
date Tue, 06 Jan 2009 06:29:44 +0000
parents df6d3c3574ce
children 533d37757363
files configure.ac libpurple/plugins/perl/perl-handlers.c
diffstat 2 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Tue Jan 06 05:36:39 2009 +0000
+++ b/configure.ac	Tue Jan 06 06:29:44 2009 +0000
@@ -2285,6 +2285,30 @@
         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 #######################################################################
--- a/libpurple/plugins/perl/perl-handlers.c	Tue Jan 06 05:36:39 2009 +0000
+++ b/libpurple/plugins/perl/perl-handlers.c	Tue Jan 06 06:29:44 2009 +0000
@@ -289,14 +289,18 @@
 	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]);