This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
"weak" references internals, still needs perlguts documentation
[perl5.git] / sv.h
diff --git a/sv.h b/sv.h
index 533b4c4..cc8c6bc 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -165,6 +165,8 @@ struct io {
 #define SVphv_SHAREKEYS 0x20000000     /* keys live on shared string table */
 #define SVphv_LAZYDEL  0x40000000      /* entry in xhv_eiter must be deleted */
 
+#define SVprv_WEAKREF   0x80000000      /* Weak reference */
+
 struct xrv {
     SV *       xrv_rv;         /* pointer to another SV */
 };
@@ -410,6 +412,11 @@ struct xpvio {
 */
 #define Gv_AMG(stash)           (PL_amagic_generation && Gv_AMupdate(stash))
 
+#define SvWEAKREF(sv)          ((SvFLAGS(sv) & (SVf_ROK|SVprv_WEAKREF)) \
+                                 == (SVf_ROK|SVprv_WEAKREF))
+#define SvWEAKREF_on(sv)       (SvFLAGS(sv) |=  (SVf_ROK|SVprv_WEAKREF))
+#define SvWEAKREF_off(sv)      (SvFLAGS(sv) &= ~(SVf_ROK|SVprv_WEAKREF))
+
 #define SvTHINKFIRST(sv)       (SvFLAGS(sv) & SVf_THINKFIRST)
 
 #define SvPADBUSY(sv)          (SvFLAGS(sv) & SVs_PADBUSY)