Integrate thrperl 5.003->5.004.
[p5sagit/p5-mst-13.2.git] / sv.h
diff --git a/sv.h b/sv.h
index acd5839..f52c09d 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -131,6 +131,10 @@ struct io {
 #define SVphv_SHAREKEYS 0x20000000     /* keys live on shared string table */
 #define SVphv_LAZYDEL  0x40000000      /* entry in xhv_eiter must be deleted */
 
+#ifdef USE_THREADS
+#define SVp_SYNC       0x10000000      /* Synchronised CV or an SV lock */
+#endif /* USE_THREADS */
+
 struct xrv {
     SV *       xrv_rv;         /* pointer to another SV */
 };
@@ -557,20 +561,36 @@ SV *newRV_noinc _((SV *));
 
 #define SvSETMAGIC(x) if (SvSMAGICAL(x)) mg_set(x)
 
-#define SvSetSV(dst,src) if ((dst) != (src)) sv_setsv(dst,src)
-
-#define SvSetSV_nosteal(dst,src) \
+#define SvSetSV_and(dst,src,finally) \
+           if ((dst) != (src)) {                       \
+               sv_setsv(dst, src);                     \
+               finally;                                \
+           }
+#define SvSetSV_nosteal_and(dst,src,finally) \
            if ((dst) != (src)) {                       \
                U32 tMpF = SvFLAGS(src) & SVs_TEMP;     \
                SvTEMP_off(src);                        \
                sv_setsv(dst, src);                     \
                SvFLAGS(src) |= tMpF;                   \
+               finally;                                \
            }
 
+#define SvSetSV(dst,src) \
+               SvSetSV_and(dst,src,/*nothing*/;)
+#define SvSetSV_nosteal(dst,src) \
+               SvSetSV_nosteal_and(dst,src,/*nothing*/;)
+
+#define SvSetMagicSV(dst,src) \
+               SvSetSV_and(dst,src,SvSETMAGIC(dst))
+#define SvSetMagicSV_nosteal(dst,src) \
+               SvSetSV_nosteal_and(dst,src,SvSETMAGIC(dst))
+
 #define SvPEEK(sv) sv_peek(sv)
 
 #define SvIMMORTAL(sv) ((sv)==&sv_undef || (sv)==&sv_yes || (sv)==&sv_no)
 
+#define boolSV(b) ((b) ? &sv_yes : &sv_no)
+
 #define isGV(sv) (SvTYPE(sv) == SVt_PVGV)
 
 #ifndef DOSISH