summaryrefslogtreecommitdiff
path: root/hv.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-10-27 20:25:46 +0000
committerDavid Mitchell <davem@iabyn.com>2009-03-29 21:48:25 +0100
commit2a753ebd90d8f342ca7409921609457115214669 (patch)
tree84c277c61f46b78ed0c23d534cb14f124d657305 /hv.h
parent31b85d28610fd3d7262773f0d04ee3a81afb4773 (diff)
downloadperl-2a753ebd90d8f342ca7409921609457115214669.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 (cherry-picked from commit b1bc3f345d4dfe19cd94c120c46649336b5cb92b)
Diffstat (limited to 'hv.h')
-rw-r--r--hv.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/hv.h b/hv.h
index d3760feb1e..f9a38856a4 100644
--- a/hv.h
+++ b/hv.h
@@ -416,7 +416,7 @@ C<SV*>.
#define HV_ITERNEXT_WANTPLACEHOLDERS 0x01 /* Don't skip placeholders. */
#define hv_iternext(hv) hv_iternext_flags(hv, 0)
-#define hv_magic(hv, gv, how) sv_magic((SV*)(hv), (SV*)(gv), how, NULL, 0)
+#define hv_magic(hv, gv, how) sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0)
/* available as a function in hv.c */
#define Perl_sharepvn(sv, len, hash) HEK_KEY(share_hek(sv, len, hash))
@@ -440,8 +440,8 @@ C<SV*>.
((HE *) hv_common((hv), (keysv), NULL, 0, 0, \
((lval) ? HV_FETCH_LVALUE : 0), NULL, (hash)))
#define hv_delete_ent(hv, key, flags, hash) \
- ((SV *) hv_common((hv), (key), NULL, 0, 0, (flags) | HV_DELETE, \
- NULL, (hash)))
+ (MUTABLE_SV(hv_common((hv), (key), NULL, 0, 0, (flags) | HV_DELETE, \
+ NULL, (hash))))
#define hv_store_flags(hv, key, klen, val, hash, flags) \
((SV**) hv_common((hv), NULL, (key), (klen), (flags), \
@@ -463,8 +463,8 @@ C<SV*>.
: HV_FETCH_JUST_SV, NULL, 0))
#define hv_delete(hv, key, klen, flags) \
- ((SV*) hv_common_key_len((hv), (key), (klen), \
- (flags) | HV_DELETE, NULL, 0))
+ (MUTABLE_SV(hv_common_key_len((hv), (key), (klen), \
+ (flags) | HV_DELETE, NULL, 0)))
/* This refcounted he structure is used for storing the hints used for lexical
pragmas. Without threads, it's basically struct he + refcount.