PerlIO * xio_ofp; /* but sockets need separate streams */
/* Cray addresses everything by word boundaries (64 bits) and
* code and data pointers cannot be mixed (which is exactly what
- * Perl_filter_add() tries to do), hence the following
+ * Perl_filter_add() tries to do with the dirp), hence the following
* union trick (as suggested by Gurusamy Sarathy).
* For further information see Geir Johansen's problem report titled
[ID 20000612.002] Perl problem on Cray system
+ * The any pointer (known as IoANY()) will also be a good place
+ * to hang any IO disciplines to.
*/
union {
DIR * xiou_dirp; /* for opendir, readdir, etc */
- void * xiou_dummy; /* for alignment */
+ void * xiou_any; /* for alignment */
} xio_dirpu;
long xio_lines; /* $. */
long xio_page; /* $% */
char xio_type;
char xio_flags;
};
-#define xio_dirp xio_dirpu.xiou_dirp
+#define xio_dirp xio_dirpu.xiou_dirp
+#define xio_any xio_dirpu.xiou_any
#define IOf_ARGV 1 /* this fp iterates over ARGV */
#define IOf_START 2 /* check for null ARGV and substitute '-' */
#define IoIFP(sv) ((XPVIO*) SvANY(sv))->xio_ifp
#define IoOFP(sv) ((XPVIO*) SvANY(sv))->xio_ofp
#define IoDIRP(sv) ((XPVIO*) SvANY(sv))->xio_dirp
+#define IoANY(sv) ((XPVIO*) SvANY(sv))->xio_any
#define IoLINES(sv) ((XPVIO*) SvANY(sv))->xio_lines
#define IoPAGE(sv) ((XPVIO*) SvANY(sv))->xio_page
#define IoPAGE_LEN(sv) ((XPVIO*) SvANY(sv))->xio_page_len
* store private buffers and state information.
*
* The supplied datasv parameter is upgraded to a PVIO type
- * and the IoDIRP field is used to store the function pointer,
+ * and the IoDIRP/IoANY field is used to store the function pointer,
* and IOf_FAKE_DIRP is enabled on datasv to mark this as such.
* Note that IoTOP_NAME, IoFMT_NAME, IoBOTTOM_NAME, if set for
* private use must be set using malloc'd pointers.
datasv = NEWSV(255,0);
if (!SvUPGRADE(datasv, SVt_PVIO))
Perl_die(aTHX_ "Can't upgrade filter_add data to SVt_PVIO");
- IoDIRP(datasv) = (DIR*)funcp; /* stash funcp into spare field */
+ IoANY(datasv) = (void *)funcp; /* stash funcp into spare field */
IoFLAGS(datasv) |= IOf_FAKE_DIRP;
DEBUG_P(PerlIO_printf(Perl_debug_log, "filter_add func %p (%s)\n",
funcp, SvPV_nolen(datasv)));
return;
/* if filter is on top of stack (usual case) just pop it off */
datasv = FILTER_DATA(AvFILLp(PL_rsfp_filters));
- if (IoDIRP(datasv) == (DIR*)funcp) {
+ if (IoANY(datasv) == (void *)funcp) {
IoFLAGS(datasv) &= ~IOf_FAKE_DIRP;
- IoDIRP(datasv) = (DIR*)NULL;
+ IoANY(datasv) = (void *)NULL;
sv_free(av_pop(PL_rsfp_filters));
return;
return FILTER_READ(idx+1, buf_sv, maxlen); /* recurse */
}
/* Get function pointer hidden within datasv */
- funcp = (filter_t)IoDIRP(datasv);
+ funcp = (filter_t)IoANY(datasv);
DEBUG_P(PerlIO_printf(Perl_debug_log,
"filter_read %d: via function %p (%s)\n",
idx, funcp, SvPV_nolen(datasv)));