summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-10-07 15:38:56 +0100
committerDavid Mitchell <davem@iabyn.com>2011-10-07 20:07:48 +0100
commit9a214eecd07ed44274740f81d8dce0e526badf80 (patch)
tree1e33a4db9f23d13f72f267978a83a39188677a11 /sv.h
parentd0c0e7dd0ccf3d5c2f658529d3ee578a0bcb116e (diff)
downloadperl-9a214eecd07ed44274740f81d8dce0e526badf80.tar.gz
make SVs_PADTMP and SVs_PADSTALE share a bit
SVs_PADSTALE is only meaningful with SVs_PADMY, while SVs_PADTMP is only meaningful with !SVs_PADMY, so let them share the same flag bit. Note that this doesn't yet free a bit in SvFLAGS, as the two bits are also used for SVpad_STATE, SVpad_TYPED. (This is is follow-on to 62bb6514085e5eddc42b4fdaf3713ccdb7f1da85.)
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h48
1 files changed, 28 insertions, 20 deletions
diff --git a/sv.h b/sv.h
index bbf41c84f6..5324256d24 100644
--- a/sv.h
+++ b/sv.h
@@ -310,9 +310,10 @@ perform the upgrade if necessary. See C<svtype>.
CvIMPORTED_CV_ON() if it needs to be
expanded to a real GV */
-#define SVs_PADSTALE 0x00010000 /* lexical has gone out of scope */
#define SVpad_STATE 0x00010000 /* pad name is a "state" var */
-#define SVs_PADTMP 0x00020000 /* in use as tmp */
+#define SVs_PADTMP 0x00020000 /* in use as tmp; only if ! SVs_PADMY */
+#define SVs_PADSTALE 0x00020000 /* lexical has gone out of scope;
+ only valid for SVs_PADMY */
#define SVpad_TYPED 0x00020000 /* pad name is a Typed Lexical */
#define SVs_PADMY 0x00040000 /* in use a "my" variable */
#define SVpad_OUR 0x00040000 /* pad name is "our" instead of "my" */
@@ -909,34 +910,41 @@ the scalar's value cannot change unless written to.
#define SvTHINKFIRST(sv) (SvFLAGS(sv) & SVf_THINKFIRST)
-#define SvPADSTALE(sv) (SvFLAGS(sv) & SVs_PADSTALE)
-#define SvPADSTALE_off(sv) (SvFLAGS(sv) &= ~SVs_PADSTALE)
+#define SvPADMY(sv) (SvFLAGS(sv) & SVs_PADMY)
+#define SvPADMY_on(sv) (SvFLAGS(sv) |= SVs_PADMY)
-#define SvPADTMP(sv) (SvFLAGS(sv) & SVs_PADTMP)
-#define SvPADTMP_off(sv) (SvFLAGS(sv) &= ~SVs_PADTMP)
+/* SVs_PADTMP and SVs_PADSTALE share the same bit, mediated by SVs_PADMY */
-#define SvPADMY(sv) (SvFLAGS(sv) & SVs_PADMY)
+#define SvPADTMP(sv) ((SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP)) == SVs_PADTMP)
+#define SvPADSTALE(sv) ((SvFLAGS(sv) & (SVs_PADMY|SVs_PADSTALE)) \
+ == (SVs_PADMY|SVs_PADSTALE))
#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
-# define SvPADTMP_on(sv) ({ \
- SV *const _svpad = MUTABLE_SV(sv); \
- assert(!(SvFLAGS(_svpad) & (SVs_PADMY|SVs_PADSTALE))); \
- (SvFLAGS(_svpad) |= SVs_PADTMP); \
+# define SvPADTMP_on(sv) ({ \
+ SV *const _svpad = MUTABLE_SV(sv); \
+ assert(!(SvFLAGS(_svpad) & SVs_PADMY)); \
+ SvFLAGS(_svpad) |= SVs_PADTMP; \
})
-# define SvPADMY_on(sv) ({ \
- SV *const _svpad = MUTABLE_SV(sv); \
- assert(!(SvFLAGS(_svpad) & SVs_PADTMP)); \
- (SvFLAGS(_svpad) |= SVs_PADMY); \
+# define SvPADTMP_off(sv) ({ \
+ SV *const _svpad = MUTABLE_SV(sv); \
+ assert(!(SvFLAGS(_svpad) & SVs_PADMY)); \
+ SvFLAGS(_svpad) &= ~SVs_PADTMP; \
})
-# define SvPADSTALE_on(sv) ({ \
- SV *const _svpad = MUTABLE_SV(sv); \
- assert(!(SvFLAGS(_svpad) & SVs_PADTMP)); \
- (SvFLAGS(_svpad) |= SVs_PADSTALE); \
+# define SvPADSTALE_on(sv) ({ \
+ SV *const _svpad = MUTABLE_SV(sv); \
+ assert(SvFLAGS(_svpad) & SVs_PADMY); \
+ SvFLAGS(_svpad) |= SVs_PADSTALE; \
+ })
+# define SvPADSTALE_off(sv) ({ \
+ SV *const _svpad = MUTABLE_SV(sv); \
+ assert(SvFLAGS(_svpad) & SVs_PADMY); \
+ SvFLAGS(_svpad) &= ~SVs_PADSTALE; \
})
#else
# define SvPADTMP_on(sv) (SvFLAGS(sv) |= SVs_PADTMP)
-# define SvPADMY_on(sv) (SvFLAGS(sv) |= SVs_PADMY)
+# define SvPADTMP_off(sv) (SvFLAGS(sv) &= ~SVs_PADTMP)
# define SvPADSTALE_on(sv) (SvFLAGS(sv) |= SVs_PADSTALE)
+# define SvPADSTALE_off(sv) (SvFLAGS(sv) &= ~SVs_PADSTALE)
#endif
#define SvTEMP(sv) (SvFLAGS(sv) & SVs_TEMP)