From 388dfe0e1f32cf379f30ac6486e4926e8461fcc5 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 10 Feb 2009 21:31:17 +0100 Subject: [PATCH] perl plugin, configure: Check for struct mgvtbl.svt_local. This member has been introduced in Perl 5.10 (I guess). To be able to correctly (statically) initialize the magic tables used to access global variables, we now check for its existence and then initialize the structs accordingly. --- configure.in | 27 +++++++++++++++++++++++++++ src/perl.c | 14 ++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 3c57a591..d8cee585 100644 --- a/configure.in +++ b/configure.in @@ -1986,6 +1986,33 @@ then fi AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE, test "x$have_broken_perl_load_module" = "xyes") + +if test "x$with_libperl" = "xyes" +then + SAVE_CFLAGS=$CFLAGS + SAVE_LDFLAGS=$LDFLAGS + CFLAGS="$CFLAGS $PERL_CFLAGS" + LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + + AC_CHECK_MEMBER( + [struct mgvtbl.svt_local], + [have_struct_mgvtbl_svt_local="yes"], + [have_struct_mgvtbl_svt_local="no"], + [ +#include +#include +#include + ]) + + if test "x$have_struct_mgvtbl_svt_local" = "xyes" + then + AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1, + [Define if Perl's struct mgvtbl has member svt_local.]) + fi + + CFLAGS=$SAVE_CFLAGS + LDFLAGS=$SAVE_LDFLAGS +fi # }}} # --with-libpq {{{ diff --git a/src/perl.c b/src/perl.c index 9413d2cb..27abc623 100644 --- a/src/perl.c +++ b/src/perl.c @@ -1576,8 +1576,18 @@ static int g_iv_set (pTHX_ SV *var, MAGIC *mg) return 0; } /* static int g_iv_set (pTHX_ SV *, MAGIC *) */ -static MGVTBL g_pv_vtbl = { g_pv_get, g_pv_set, NULL, NULL, NULL, NULL, NULL }; -static MGVTBL g_iv_vtbl = { g_iv_get, g_iv_set, NULL, NULL, NULL, NULL, NULL }; +static MGVTBL g_pv_vtbl = { + g_pv_get, g_pv_set, NULL, NULL, NULL, NULL, NULL +#if HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL + , NULL +#endif +}; +static MGVTBL g_iv_vtbl = { + g_iv_get, g_iv_set, NULL, NULL, NULL, NULL, NULL +#if HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL + , NULL +#endif +}; /* bootstrap the Collectd module */ static void xs_init (pTHX) -- 2.30.2