From: Vincent Pit Date: Tue, 25 Aug 2009 15:04:43 +0000 (+0200) Subject: Introduce VMG_FORKSAFE X-Git-Tag: v0.37~1 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=1ff75d21f8a370b6533873480725f78eebd70efc;p=perl%2Fmodules%2FVariable-Magic.git Introduce VMG_FORKSAFE --- diff --git a/Magic.xs b/Magic.xs index 77b6209..1dada02 100644 --- a/Magic.xs +++ b/Magic.xs @@ -36,6 +36,11 @@ # define dNOOP #endif +/* Safe unless stated otherwise in Makefile.PL */ +#ifndef VMG_FORKSAFE +# define VMG_FORKSAFE 1 +#endif + #ifndef VMG_MULTIPLICITY # if defined(MULTIPLICITY) || defined(PERL_IMPLICIT_CONTEXT) # define VMG_MULTIPLICITY 1 @@ -1263,6 +1268,7 @@ BOOT: newSVuv(VMG_COMPAT_SCALAR_LENGTH_NOLEN)); newCONSTSUB(stash, "VMG_PERL_PATCHLEVEL", newSVuv(VMG_PERL_PATCHLEVEL)); newCONSTSUB(stash, "VMG_THREADSAFE", newSVuv(VMG_THREADSAFE)); + newCONSTSUB(stash, "VMG_FORKSAFE", newSVuv(VMG_FORKSAFE)); newCONSTSUB(stash, "VMG_OP_INFO_NAME", newSVuv(VMG_OP_INFO_NAME)); newCONSTSUB(stash, "VMG_OP_INFO_OBJECT", newSVuv(VMG_OP_INFO_OBJECT)); } diff --git a/Makefile.PL b/Makefile.PL index 5d698c6..b3a340e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -45,6 +45,11 @@ if ($^O eq 'MSWin32' && $^V lt v5.9.0) { push @DEFINES, '-DVMG_MULTIPLICITY=0'; } +# Fork emulation got "fixed" in 5.10.1 +if ($^O eq 'MSWin32' && $^V lt v5.10.1) { + push @DEFINES, '-DVMG_FORKSAFE=0'; +} + @DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES; my $dist = 'Variable-Magic'; diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index 1ac6898..954297e 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -473,6 +473,11 @@ The perl patchlevel this module was built with, or C<0> for non-debugging perls. True iff this module could have been built with thread-safety features enabled. +=head2 C + +True iff this module could have been built with fork-safety features enabled. +This will always be true except on Windows where it's false for perl 5.10.0 and below . + =head2 C Value to pass with C to get the current op name in the magic callbacks. @@ -554,7 +559,7 @@ our %EXPORT_TAGS = ( qw/SIG_MIN SIG_MAX SIG_NBR MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR/, qw/VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR VMG_COMPAT_SCALAR_LENGTH_NOLEN/, qw/VMG_PERL_PATCHLEVEL/, - qw/VMG_THREADSAFE/, + qw/VMG_THREADSAFE VMG_FORKSAFE/, qw/VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT/ ] ); diff --git a/t/01-import.t b/t/01-import.t index f02df0e..67cf438 100644 --- a/t/01-import.t +++ b/t/01-import.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More tests => 22; require Variable::Magic; @@ -13,7 +13,7 @@ for (qw/wizard gensig getsig cast getdata dispell VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR VMG_COMPAT_SCALAR_LENGTH_NOLEN VMG_PERL_PATCHLEVEL - VMG_THREADSAFE + VMG_THREADSAFE VMG_FORKSAFE VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT/) { eval { Variable::Magic->import($_) }; is($@, '', 'import ' . $_);