summaryrefslogtreecommitdiff
path: root/pad.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-10-27 20:25:46 +0000
committerNicholas Clark <nick@ccl4.org>2008-10-27 20:25:46 +0000
commitb1bc3f345d4dfe19cd94c120c46649336b5cb92b (patch)
treebdfcef0c7875037af6a5fa8195d2203fe76e6b27 /pad.h
parentbb5dd93d07e2d54d352e519c7b43ff2d3e5c5f36 (diff)
downloadperl-b1bc3f345d4dfe19cd94c120c46649336b5cb92b.tar.gz
Add a macro MUTABLE_PTR(p), which on (non-pedantic) gcc will not cast
away const, returning a void *. Add MUTABLE_SV(sv) which uses this, and replace all (SV *) casts either with MUTABLE_SV(sv), or (const SV *). This probably still needs some work - assigning to SvPVX() and SvRV() is now likely to generate a casting error. The core doesn't do this. But as-is it's finding bugs that can be fixed. p4raw-id: //depot/perl@34605
Diffstat (limited to 'pad.h')
-rw-r--r--pad.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/pad.h b/pad.h
index 647db33bb5..2f0fb7c7d1 100644
--- a/pad.h
+++ b/pad.h
@@ -37,7 +37,7 @@ typedef U64TYPE PADOFFSET;
#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
# define COP_SEQ_RANGE_LOW(sv) \
- (({ SV *const _sv_cop_seq_range_low = (SV *) (sv); \
+ (({ const SV *const _sv_cop_seq_range_low = (const SV *) (sv); \
assert(SvTYPE(_sv_cop_seq_range_low) == SVt_NV \
|| SvTYPE(_sv_cop_seq_range_low) >= SVt_PVNV); \
assert(SvTYPE(_sv_cop_seq_range_low) != SVt_PVAV); \
@@ -45,10 +45,10 @@ typedef U64TYPE PADOFFSET;
assert(SvTYPE(_sv_cop_seq_range_low) != SVt_PVCV); \
assert(SvTYPE(_sv_cop_seq_range_low) != SVt_PVFM); \
assert(!isGV_with_GP(_sv_cop_seq_range_low)); \
- ((XPVNV*) SvANY(_sv_cop_seq_range_low))->xnv_u.xpad_cop_seq.xlow; \
+ ((XPVNV*) MUTABLE_PTR(SvANY(_sv_cop_seq_range_low)))->xnv_u.xpad_cop_seq.xlow; \
}))
# define COP_SEQ_RANGE_HIGH(sv) \
- (({ SV *const _sv_cop_seq_range_high = (SV *) (sv); \
+ (({ const SV *const _sv_cop_seq_range_high = (const SV *) (sv); \
assert(SvTYPE(_sv_cop_seq_range_high) == SVt_NV \
|| SvTYPE(_sv_cop_seq_range_high) >= SVt_PVNV); \
assert(SvTYPE(_sv_cop_seq_range_high) != SVt_PVAV); \
@@ -56,10 +56,10 @@ typedef U64TYPE PADOFFSET;
assert(SvTYPE(_sv_cop_seq_range_high) != SVt_PVCV); \
assert(SvTYPE(_sv_cop_seq_range_high) != SVt_PVFM); \
assert(!isGV_with_GP(_sv_cop_seq_range_high)); \
- ((XPVNV*) SvANY(_sv_cop_seq_range_high))->xnv_u.xpad_cop_seq.xhigh; \
+ ((XPVNV*) MUTABLE_PTR(SvANY(_sv_cop_seq_range_high)))->xnv_u.xpad_cop_seq.xhigh; \
}))
# define PARENT_PAD_INDEX(sv) \
- (({ SV *const _sv_parent_pad_index = (SV *) (sv); \
+ (({ const SV *const _sv_parent_pad_index = (const SV *) (sv); \
assert(SvTYPE(_sv_parent_pad_index) == SVt_NV \
|| SvTYPE(_sv_parent_pad_index) >= SVt_PVNV); \
assert(SvTYPE(_sv_parent_pad_index) != SVt_PVAV); \
@@ -67,10 +67,10 @@ typedef U64TYPE PADOFFSET;
assert(SvTYPE(_sv_parent_pad_index) != SVt_PVCV); \
assert(SvTYPE(_sv_parent_pad_index) != SVt_PVFM); \
assert(!isGV_with_GP(_sv_parent_pad_index)); \
- ((XPVNV*) SvANY(_sv_parent_pad_index))->xnv_u.xpad_cop_seq.xlow; \
+ ((XPVNV*) MUTABLE_PTR(SvANY(_sv_parent_pad_index)))->xnv_u.xpad_cop_seq.xlow; \
}))
# define PARENT_FAKELEX_FLAGS(sv) \
- (({ SV *const _sv_parent_fakelex_flags = (SV *) (sv); \
+ (({ const SV *const _sv_parent_fakelex_flags = (const SV *) (sv); \
assert(SvTYPE(_sv_parent_fakelex_flags) == SVt_NV \
|| SvTYPE(_sv_parent_fakelex_flags) >= SVt_PVNV); \
assert(SvTYPE(_sv_parent_fakelex_flags) != SVt_PVAV); \
@@ -78,7 +78,7 @@ typedef U64TYPE PADOFFSET;
assert(SvTYPE(_sv_parent_fakelex_flags) != SVt_PVCV); \
assert(SvTYPE(_sv_parent_fakelex_flags) != SVt_PVFM); \
assert(!isGV_with_GP(_sv_parent_fakelex_flags)); \
- ((XPVNV*) SvANY(_sv_parent_fakelex_flags))->xnv_u.xpad_cop_seq.xhigh; \
+ ((XPVNV*) MUTABLE_PTR(SvANY(_sv_parent_fakelex_flags)))->xnv_u.xpad_cop_seq.xhigh; \
}))
#else
# define COP_SEQ_RANGE_LOW(sv) \