From: Jarkko Hietaniemi Date: Fri, 7 Jul 2000 14:03:40 +0000 (+0000) Subject: Fix the alignment problem in Crays ([ID 20000612.002]). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=81bf48a6dbba4b295dfa172a17ca70b654dbf225;p=p5sagit%2Fp5-mst-13.2.git Fix the alignment problem in Crays ([ID 20000612.002]). p4raw-id: //depot/cfgperl@6324 --- diff --git a/sv.h b/sv.h index 23cf29e..b77a9d3 100644 --- a/sv.h +++ b/sv.h @@ -365,14 +365,16 @@ struct xpvio { 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; /* $% */ @@ -388,7 +390,8 @@ struct xpvio { 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 '-' */ @@ -715,6 +718,7 @@ Set the length of the string which is in the SV. See C. #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 diff --git a/toke.c b/toke.c index fc51d91..49a16b4 100644 --- a/toke.c +++ b/toke.c @@ -1875,7 +1875,7 @@ S_incl_perldb(pTHX) * 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. @@ -1893,7 +1893,7 @@ Perl_filter_add(pTHX_ filter_t funcp, SV *datasv) 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))); @@ -1913,9 +1913,9 @@ Perl_filter_del(pTHX_ filter_t funcp) 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; @@ -1975,7 +1975,7 @@ Perl_filter_read(pTHX_ int idx, SV *buf_sv, int maxlen) 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)));