This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gv.c: gv_fetchmeth_pvn UTF8 cleanup.
[perl5.git] / pp.h
diff --git a/pp.h b/pp.h
index 0ba877f..ad71668 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -496,12 +496,28 @@ True if this op will be the return value of an lvalue subroutine
   )
 
 #ifdef PERL_CORE
+
 /* These are just for Perl_tied_method(), which is not part of the public API.
    Use 0x04 rather than the next available bit, to help the compiler if the
    architecture can generate more efficient instructions.  */
 #  define TIED_METHOD_MORTALIZE_NOT_NEEDED     0x04
 #  define TIED_METHOD_ARGUMENTS_ON_STACK       0x08
 #  define TIED_METHOD_SAY                      0x10
+
+/* Used in various places that need to dereference a glob or globref */
+#  define MAYBE_DEREF_GV_flags(sv,phlags)                          \
+    (                                                               \
+       (void)(phlags & SV_GMAGIC && (SvGETMAGIC(sv),0)),            \
+       isGV_with_GP(sv)                                              \
+         ? (GV *)sv                                                   \
+         : SvROK(sv) && SvTYPE(SvRV(sv)) <= SVt_PVLV &&               \
+           (SvGETMAGIC(SvRV(sv)), isGV_with_GP(SvRV(sv)))              \
+            ? (GV *)SvRV(sv)                                            \
+            : NULL                                                       \
+    )
+#  define MAYBE_DEREF_GV(sv)      MAYBE_DEREF_GV_flags(sv,SV_GMAGIC)
+#  define MAYBE_DEREF_GV_nomg(sv) MAYBE_DEREF_GV_flags(sv,0)
+
 #endif
 
 /*