perl plugin, configure: Check for struct mgvtbl.svt_local.
authorSebastian Harl <sh@tokkee.org>
Tue, 10 Feb 2009 20:31:17 +0000 (21:31 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 10 Feb 2009 20:31:17 +0000 (21:31 +0100)
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
src/perl.c

index 3c57a59..d8cee58 100644 (file)
@@ -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 <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+               ])
+
+       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 {{{
index 9413d2c..27abc62 100644 (file)
@@ -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)