From: Nicholas Clark Date: Mon, 27 Oct 2008 21:23:04 +0000 (+0000) Subject: Add MUTABLE_AV(), and remove (AV *) casts from headers. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a062e10d14f53c3718ae4dbf13be27233d85afcc;p=p5sagit%2Fp5-mst-13.2.git Add MUTABLE_AV(), and remove (AV *) casts from headers. p4raw-id: //depot/perl@34608 --- diff --git a/av.h b/av.h index c48df39..77df033 100644 --- a/av.h +++ b/av.h @@ -75,7 +75,7 @@ Same as C. Deprecated, use C instead. #define AvALLOC(av) (*((SV***)&((XPVAV*) SvANY(av))->xav_alloc)) #define AvMAX(av) ((XPVAV*) SvANY(av))->xav_max #define AvFILLp(av) ((XPVAV*) SvANY(av))->xav_fill -#define AvARYLEN(av) (*Perl_av_arylen_p(aTHX_ (AV*)av)) +#define AvARYLEN(av) (*Perl_av_arylen_p(aTHX_ MUTABLE_AV(av))) #define AvREAL(av) (SvFLAGS(av) & SVpav_REAL) #define AvREAL_on(av) (SvFLAGS(av) |= SVpav_REAL) @@ -101,7 +101,7 @@ Creates a new AV. The reference count is set to 1. =cut */ -#define newAV() ((AV *)newSV_type(SVt_PVAV)) +#define newAV() MUTABLE_AV(newSV_type(SVt_PVAV)) /* * Local variables: diff --git a/handy.h b/handy.h index d6a9026..cd6e4cb 100644 --- a/handy.h +++ b/handy.h @@ -54,6 +54,7 @@ Null SV pointer. (No longer available when C is defined.) # define MUTABLE_PTR(p) ((void *) (p)) #endif +#define MUTABLE_AV(p) ((AV *)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/pad.h b/pad.h index 2f0fb7c..10e094e 100644 --- a/pad.h +++ b/pad.h @@ -210,7 +210,7 @@ Restore the old pad saved into the local variable opad by PAD_SAVE_LOCAL() #define PAD_BASE_SV(padlist, po) \ (AvARRAY(padlist)[1]) \ - ? AvARRAY((AV*)(AvARRAY(padlist)[1]))[po] : NULL; + ? AvARRAY(MUTABLE_AV((AvARRAY(padlist)[1])))[po] : NULL; #define PAD_SET_CUR_NOSAVE(padlist,nth) \ @@ -258,7 +258,7 @@ context block structure (can be used as an lvalue). */ #define CX_CURPAD_SAVE(block) (block).oldcomppad = PL_comppad -#define CX_CURPAD_SV(block,po) (AvARRAY((AV*)((block).oldcomppad))[po]) +#define CX_CURPAD_SV(block,po) (AvARRAY(MUTABLE_AV(((block).oldcomppad)))[po]) /* @@ -337,7 +337,7 @@ Clone the state variables associated with running and compiling pads. * sub's CV or padlist. */ #define PAD_CLONE_VARS(proto_perl, param) \ - PL_comppad = (AV *) ptr_table_fetch(PL_ptr_table, proto_perl->Icomppad); \ + PL_comppad = MUTABLE_AV(ptr_table_fetch(PL_ptr_table, proto_perl->Icomppad)); \ PL_curpad = PL_comppad ? AvARRAY(PL_comppad) : NULL; \ PL_comppad_name = av_dup(proto_perl->Icomppad_name, param); \ PL_comppad_name_fill = proto_perl->Icomppad_name_fill; \ diff --git a/thread.h b/thread.h index 655e827..7718d4b 100644 --- a/thread.h +++ b/thread.h @@ -156,7 +156,7 @@ #define THREAD_RET_CAST(x) ((any_t) x) #define DETACH(t) cthread_detach(t->self) -#define JOIN(t, avp) (*(avp) = (AV *)cthread_join(t->self)) +#define JOIN(t, avp) (*(avp) = MUTABLE_AV(cthread_join(t->self))) #define PERL_SET_CONTEXT(t) cthread_set_data(cthread_self(), t) #define PERL_GET_CONTEXT cthread_data(cthread_self())