]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - lib/Variable/Magic.pm
Make the module threadsafe by adding a CLONE method that clones the global state...
[perl/modules/Variable-Magic.git] / lib / Variable / Magic.pm
index ffc67b4c4d6d2d1ea09c6331b7c7d8b5936711e5..af2762db066577e372fc7b918b593c468a377490 100644 (file)
@@ -213,6 +213,10 @@ True for perls that don't call 'len' magic when taking the C<length> of a magica
 
 The perl patchlevel this module was built with, or C<0> for non-debugging perls.
 
+=head2 C<VMG_THREADSAFE>
+
+True iff this module could have been built with thread-safety features enabled.
+
 =head1 FUNCTIONS
 
 =cut
@@ -277,7 +281,12 @@ sub wizard {
  push @cbs, 'dup'   if MGf_DUP;
  push @cbs, 'local' if MGf_LOCAL;
  push @cbs, qw/fetch store exists delete/ if VMG_UVAR;
- return _wizard(map $opts{$_}, @cbs);
+ my $ret = eval { _wizard(map $opts{$_}, @cbs) };
+ if (my $err = $@) {
+  $err =~ s/\sat\s+.*?\n//;
+  croak $err;
+ }
+ return $ret;
 }
 
 =head2 C<gensig>
@@ -340,7 +349,8 @@ our %EXPORT_TAGS    = (
  'consts' => [ qw/SIG_MIN SIG_MAX SIG_NBR MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR/,
                qw/VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNDEF_CLEAR/,
                qw/VMG_COMPAT_SCALAR_LENGTH_NOLEN/,
-               qw/VMG_PERL_PATCHLEVEL/ ]
+               qw/VMG_PERL_PATCHLEVEL/,
+               qw/VMG_THREADSAFE/ ]
 );
 our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];