summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doio.c2
-rw-r--r--gv.c2
-rw-r--r--handy.h1
-rw-r--r--perl.c6
-rw-r--r--pp.c2
-rw-r--r--pp_sys.c4
-rw-r--r--sv.c10
7 files changed, 14 insertions, 13 deletions
diff --git a/doio.c b/doio.c
index b0dd4f26fc..506470504e 100644
--- a/doio.c
+++ b/doio.c
@@ -1316,7 +1316,7 @@ Perl_my_stat(pTHX)
goto do_fstat;
}
else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) {
- io = (IO*)SvRV(sv);
+ io = MUTABLE_IO(SvRV(sv));
gv = NULL;
goto do_fstat_have_io;
}
diff --git a/gv.c b/gv.c
index 77c65a4d16..aa27f4af7e 100644
--- a/gv.c
+++ b/gv.c
@@ -1499,7 +1499,7 @@ Perl_newIO(pTHX)
{
dVAR;
GV *iogv;
- IO * const io = (IO*)newSV_type(SVt_PVIO);
+ IO * const io = MUTABLE_IO(newSV_type(SVt_PVIO));
/* This used to read SvREFCNT(io) = 1;
It's not clear why the reference count needed an explicit reset. NWC
*/
diff --git a/handy.h b/handy.h
index 32239b9ee3..d488922a44 100644
--- a/handy.h
+++ b/handy.h
@@ -57,6 +57,7 @@ Null SV pointer. (No longer available when C<PERL_CORE> is defined.)
#define MUTABLE_AV(p) ((AV *)MUTABLE_PTR(p))
#define MUTABLE_CV(p) ((CV *)MUTABLE_PTR(p))
#define MUTABLE_HV(p) ((HV *)MUTABLE_PTR(p))
+#define MUTABLE_IO(p) ((IO *)MUTABLE_PTR(p))
#define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p))
/* XXX Configure ought to have a test for a boolean type, if I can
diff --git a/perl.c b/perl.c
index 7b8cd86533..cca22c59b1 100644
--- a/perl.c
+++ b/perl.c
@@ -4554,7 +4554,7 @@ S_init_predump_symbols(pTHX)
IoIFP(io) = PerlIO_stdin();
tmpgv = gv_fetchpvs("stdin", GV_ADD|GV_NOTQUAL, SVt_PV);
GvMULTI_on(tmpgv);
- GvIOp(tmpgv) = (IO*)SvREFCNT_inc_simple(io);
+ GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io));
tmpgv = gv_fetchpvs("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO);
GvMULTI_on(tmpgv);
@@ -4564,7 +4564,7 @@ S_init_predump_symbols(pTHX)
setdefout(tmpgv);
tmpgv = gv_fetchpvs("stdout", GV_ADD|GV_NOTQUAL, SVt_PV);
GvMULTI_on(tmpgv);
- GvIOp(tmpgv) = (IO*)SvREFCNT_inc_simple(io);
+ GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io));
PL_stderrgv = gv_fetchpvs("STDERR", GV_ADD|GV_NOTQUAL, SVt_PVIO);
GvMULTI_on(PL_stderrgv);
@@ -4573,7 +4573,7 @@ S_init_predump_symbols(pTHX)
IoOFP(io) = IoIFP(io) = PerlIO_stderr();
tmpgv = gv_fetchpvs("stderr", GV_ADD|GV_NOTQUAL, SVt_PV);
GvMULTI_on(tmpgv);
- GvIOp(tmpgv) = (IO*)SvREFCNT_inc_simple(io);
+ GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io));
PL_statname = newSV(0); /* last filename we did stat on */
diff --git a/pp.c b/pp.c
index fb66c08891..8234a7731e 100644
--- a/pp.c
+++ b/pp.c
@@ -139,7 +139,7 @@ PP(pp_rv2gv)
if (SvTYPE(sv) == SVt_PVIO) {
GV * const gv = (GV*) sv_newmortal();
gv_init(gv, 0, "", 0, 0);
- GvIOp(gv) = (IO *)sv;
+ GvIOp(gv) = MUTABLE_IO(sv);
SvREFCNT_inc_void_NN(sv);
sv = (SV*) gv;
}
diff --git a/pp_sys.c b/pp_sys.c
index 033482d66b..0181e7eea4 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2207,7 +2207,7 @@ PP(pp_truncate)
goto do_ftruncate_gv;
}
else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) {
- io = (IO*) SvRV(sv); /* *main::FRED{IO} for example */
+ io = MUTABLE_IO(SvRV(sv)); /* *main::FRED{IO} for example */
goto do_ftruncate_io;
}
@@ -2854,7 +2854,7 @@ PP(pp_stat)
goto do_fstat_warning_check;
goto do_fstat;
} else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) {
- io = (IO*)SvRV(sv);
+ io = MUTABLE_IO(SvRV(sv));
if (PL_op->op_type == OP_LSTAT)
goto do_fstat_warning_check;
goto do_fstat_have_io;
diff --git a/sv.c b/sv.c
index 3293a91faa..cce7b6d25c 100644
--- a/sv.c
+++ b/sv.c
@@ -4736,7 +4736,7 @@ Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const int how,
*/
if (how == PERL_MAGIC_tiedscalar && SvTYPE(sv) == SVt_PVIO &&
- obj && SvROK(obj) && GvIO(SvRV(obj)) == (IO*)sv)
+ obj && SvROK(obj) && GvIO(SvRV(obj)) == (const IO *)sv)
{
sv_rvweaken(obj);
}
@@ -5494,7 +5494,7 @@ Perl_sv_clear(pTHX_ register SV *const sv)
IoIFP(sv) != PerlIO_stdout() &&
IoIFP(sv) != PerlIO_stderr())
{
- io_close((IO*)sv, FALSE);
+ io_close(MUTABLE_IO(sv), FALSE);
}
if (IoDIRP(sv) && !(IoFLAGS(sv) & IOf_FAKE_DIRP))
PerlDir_close(IoDIRP(sv));
@@ -7889,7 +7889,7 @@ Perl_sv_2io(pTHX_ SV *const sv)
switch (SvTYPE(sv)) {
case SVt_PVIO:
- io = (IO*)sv;
+ io = MUTABLE_IO(sv);
break;
case SVt_PVGV:
if (isGV_with_GP(sv)) {
@@ -10090,8 +10090,8 @@ ptr_table_* functions.
#define hv_dup_inc(s,t) MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define cv_dup(s,t) MUTABLE_CV(sv_dup((SV*)s,t))
#define cv_dup_inc(s,t) MUTABLE_CV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
-#define io_dup(s,t) (IO*)sv_dup((SV*)s,t)
-#define io_dup_inc(s,t) (IO*)SvREFCNT_inc(sv_dup((const SV *)s,t))
+#define io_dup(s,t) MUTABLE_IO(sv_dup((SV*)s,t))
+#define io_dup_inc(s,t) MUTABLE_IO(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define gv_dup(s,t) (GV*)sv_dup((SV*)s,t)
#define gv_dup_inc(s,t) (GV*)SvREFCNT_inc(sv_dup((const SV *)s,t))
#define SAVEPV(p) ((p) ? savepv(p) : NULL)