From: Robin Barker Date: Tue, 7 Sep 1999 12:30:18 +0000 (+0100) Subject: Fix pointer casts. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=427181846486e3aa5034a647dc1922377185f4c0;p=p5sagit%2Fp5-mst-13.2.git Fix pointer casts. To: perl5-porters@perl.org Subject: [ID 19990907.004] [PATCH perl5.005_61] compiler warnings with -Duse64bits Message-Id: <199909071130.MAA11435@tempest.npl.co.uk> p4raw-id: //depot/cfgperl@4100 --- diff --git a/doio.c b/doio.c index 413e342..50870b2 100644 --- a/doio.c +++ b/doio.c @@ -1696,7 +1696,7 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp) else { IV i = SvIV(astr); - a = (char *)i; /* ouch */ + a = (char *)PTR_CAST i; /* ouch */ } SETERRNO(0,0); switch (optype) diff --git a/dump.c b/dump.c index 1ec22f2..182834e 100644 --- a/dump.c +++ b/dump.c @@ -768,7 +768,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo #ifdef IV_IS_QUAD Perl_sv_setpvf(aTHX_ d, "(0x%" PERL_PRIx64") at 0x%" PERL_PRIx64 "\n%*s REFCNT = %" PERL_PRId64 "\n%*s FLAGS = (", - (UV)SvANY(sv), (UV)sv, + (UV)PTR_CAST SvANY(sv), (UV)PTR_CAST sv, PL_dumpindent*level, "", (IV)SvREFCNT(sv), PL_dumpindent*level, ""); #else @@ -933,7 +933,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo } if (SvROK(sv)) { #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " RV = 0x%" PERL_PRIx64 "\n", (IV)SvRV(sv)); + Perl_dump_indent(aTHX_ level, file, " RV = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST SvRV(sv)); #else Perl_dump_indent(aTHX_ level, file, " RV = 0x%lx\n", (long)SvRV(sv)); #endif @@ -946,7 +946,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo if (type <= SVt_PVLV) { if (SvPVX(sv)) { #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file," PV = 0x%" PERL_PRIx64 " ", (IV)SvPVX(sv)); + Perl_dump_indent(aTHX_ level, file," PV = 0x%" PERL_PRIx64 " ", (IV)PTR_CAST SvPVX(sv)); #else Perl_dump_indent(aTHX_ level, file," PV = 0x%lx ", (long)SvPVX(sv)); #endif @@ -976,7 +976,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo #ifdef IV_IS_QUAD Perl_dump_indent(aTHX_ level, file, " TARGOFF = %" PERL_PRId64 "\n", (IV)LvTARGOFF(sv)); Perl_dump_indent(aTHX_ level, file, " TARGLEN = %" PERL_PRId64 "\n", (IV)LvTARGLEN(sv)); - Perl_dump_indent(aTHX_ level, file, " TARG = 0x%" PERL_PRIx64 "\n", (IV)LvTARG(sv)); + Perl_dump_indent(aTHX_ level, file, " TARG = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST LvTARG(sv)); #else Perl_dump_indent(aTHX_ level, file, " TARGOFF = %ld\n", (long)LvTARGOFF(sv)); Perl_dump_indent(aTHX_ level, file, " TARGLEN = %ld\n", (long)LvTARGLEN(sv)); @@ -987,14 +987,14 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo break; case SVt_PVAV: #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64 , (IV)AvARRAY(sv)); + Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64 , (IV)PTR_CAST AvARRAY(sv)); #else Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%lx", (long)AvARRAY(sv)); #endif if (AvARRAY(sv) != AvALLOC(sv)) { PerlIO_printf(file, " (offset=%d)\n", (AvARRAY(sv) - AvALLOC(sv))); #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%" PERL_PRIx64 "\n", (IV)AvALLOC(sv)); + Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST AvALLOC(sv)); #else Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%lx\n", (long)AvALLOC(sv)); #endif @@ -1004,7 +1004,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo #ifdef IV_IS_QUAD Perl_dump_indent(aTHX_ level, file, " FILL = %" PERL_PRId64 "\n", (IV)AvFILLp(sv)); Perl_dump_indent(aTHX_ level, file, " MAX = %" PERL_PRId64 "\n", (IV)AvMAX(sv)); - Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%" PERL_PRIx64 "\n", (IV)AvARYLEN(sv)); + Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST AvARYLEN(sv)); #else Perl_dump_indent(aTHX_ level, file, " FILL = %ld\n", (long)AvFILLp(sv)); Perl_dump_indent(aTHX_ level, file, " MAX = %ld\n", (long)AvMAX(sv)); @@ -1033,7 +1033,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo break; case SVt_PVHV: #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64,(IV)HvARRAY(sv)); + Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64,(IV)PTR_CAST HvARRAY(sv)); #else Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%lx",(long)HvARRAY(sv)); #endif @@ -1086,7 +1086,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo Perl_dump_indent(aTHX_ level, file, " FILL = %" PERL_PRId64 "\n", (IV)HvFILL(sv)); Perl_dump_indent(aTHX_ level, file, " MAX = %" PERL_PRId64 "\n", (IV)HvMAX(sv)); Perl_dump_indent(aTHX_ level, file, " RITER = %" PERL_PRId64 "\n", (IV)HvRITER(sv)); - Perl_dump_indent(aTHX_ level, file, " EITER = 0x%" PERL_PRIx64 "\n",(IV) HvEITER(sv)); + Perl_dump_indent(aTHX_ level, file, " EITER = 0x%" PERL_PRIx64 "\n",(IV)PTR_CAST HvEITER(sv)); #else Perl_dump_indent(aTHX_ level, file, " KEYS = %ld\n", (long)HvKEYS(sv)); Perl_dump_indent(aTHX_ level, file, " FILL = %ld\n", (long)HvFILL(sv)); @@ -1096,7 +1096,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo #endif if (HvPMROOT(sv)) #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%" PERL_PRIx64 "\n",(IV)HvPMROOT(sv)); + Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%" PERL_PRIx64 "\n",(IV)PTR_CAST HvPMROOT(sv)); #else Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%lx\n",(long)HvPMROOT(sv)); #endif @@ -1143,7 +1143,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo if (CvROOT(sv) && dumpops) do_op_dump(level+1, file, CvROOT(sv)); #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%" PERL_PRIx64 "\n", (IV)CvXSUB(sv)); + Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST CvXSUB(sv)); Perl_dump_indent(aTHX_ level, file, " XSUBANY = %" PERL_PRId64 "\n", (IV)CvXSUBANY(sv).any_i32); #else Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%lx\n", (long)CvXSUB(sv)); @@ -1177,7 +1177,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo Perl_dump_indent(aTHX_ level, file, " LINES = %ld\n", (long)FmLINES(sv)); #endif #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%" PERL_PRIx64 "\n", (IV)CvPADLIST(sv)); + Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST CvPADLIST(sv)); #else Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%lx\n", (long)CvPADLIST(sv)); #endif @@ -1217,7 +1217,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo CV *outside = CvOUTSIDE(sv); #ifdef IV_IS_QUAD Perl_dump_indent(aTHX_ level, file, " OUTSIDE = 0x%" PERL_PRIx64 " (%s)\n", - (IV)outside, + (IV)PTR_CAST outside, (!outside ? "null" : CvANON(outside) ? "ANON" : (outside == PL_main_cv) ? "MAIN" @@ -1245,14 +1245,14 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo #endif do_hv_dump (level, file, " GvSTASH", GvSTASH(sv)); #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " GP = 0x%" PERL_PRIx64 "\n", (IV)GvGP(sv)); - Perl_dump_indent(aTHX_ level, file, " SV = 0x%" PERL_PRIx64 "\n", (IV)GvSV(sv)); + Perl_dump_indent(aTHX_ level, file, " GP = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST GvGP(sv)); + Perl_dump_indent(aTHX_ level, file, " SV = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST GvSV(sv)); Perl_dump_indent(aTHX_ level, file, " REFCNT = %" PERL_PRId64 "\n", (IV)GvREFCNT(sv)); - Perl_dump_indent(aTHX_ level, file, " IO = 0x%" PERL_PRIx64 "\n", (IV)GvIOp(sv)); - Perl_dump_indent(aTHX_ level, file, " FORM = 0x%" PERL_PRIx64 " \n", (IV)GvFORM(sv)); - Perl_dump_indent(aTHX_ level, file, " AV = 0x%" PERL_PRIx64 "\n", (IV)GvAV(sv)); - Perl_dump_indent(aTHX_ level, file, " HV = 0x%" PERL_PRIx64 "\n", (IV)GvHV(sv)); - Perl_dump_indent(aTHX_ level, file, " CV = 0x%" PERL_PRIx64 "\n", (IV)GvCV(sv)); + Perl_dump_indent(aTHX_ level, file, " IO = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST GvIOp(sv)); + Perl_dump_indent(aTHX_ level, file, " FORM = 0x%" PERL_PRIx64 " \n", (IV)PTR_CAST GvFORM(sv)); + Perl_dump_indent(aTHX_ level, file, " AV = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST GvAV(sv)); + Perl_dump_indent(aTHX_ level, file, " HV = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST GvHV(sv)); + Perl_dump_indent(aTHX_ level, file, " CV = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST GvCV(sv)); Perl_dump_indent(aTHX_ level, file, " CVGEN = 0x%" PERL_PRIx64 "\n", (IV)GvCVGEN(sv)); Perl_dump_indent(aTHX_ level, file, " LASTEXPR = %" PERL_PRId64 "\n", (IV)GvLASTEXPR(sv)); Perl_dump_indent(aTHX_ level, file, " LINE = %" PERL_PRId64 "\n", (IV)GvLINE(sv)); @@ -1275,9 +1275,9 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo break; case SVt_PVIO: #ifdef IV_IS_QUAD - Perl_dump_indent(aTHX_ level, file, " IFP = 0x%" PERL_PRIx64 "\n", (IV)IoIFP(sv)); - Perl_dump_indent(aTHX_ level, file, " OFP = 0x%" PERL_PRIx64 "\n", (IV)IoOFP(sv)); - Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%" PERL_PRIx64 "\n", (IV)IoDIRP(sv)); + Perl_dump_indent(aTHX_ level, file, " IFP = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST IoIFP(sv)); + Perl_dump_indent(aTHX_ level, file, " OFP = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST IoOFP(sv)); + Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST IoDIRP(sv)); Perl_dump_indent(aTHX_ level, file, " LINES = %" PERL_PRId64 "\n", (IV)IoLINES(sv)); Perl_dump_indent(aTHX_ level, file, " PAGE = %" PERL_PRId64 "\n", (IV)IoPAGE(sv)); Perl_dump_indent(aTHX_ level, file, " PAGE_LEN = %" PERL_PRId64 "\n", (IV)IoPAGE_LEN(sv)); diff --git a/ext/B/B.xs b/ext/B/B.xs index 570b001..ad3d008 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -202,7 +202,7 @@ make_sv_object(pTHX_ SV *arg, SV *sv) } if (!type) { type = svclassnames[SvTYPE(sv)]; - iv = (IV)sv; + iv = (IV)PTR_CAST sv; } sv_setiv(newSVrv(arg, type), iv); return arg; @@ -211,7 +211,7 @@ make_sv_object(pTHX_ SV *arg, SV *sv) static SV * make_mg_object(pTHX_ SV *arg, MAGIC *mg) { - sv_setiv(newSVrv(arg, "B::MAGIC"), (IV)mg); + sv_setiv(newSVrv(arg, "B::MAGIC"), (IV)PTR_CAST mg); return arg; } @@ -317,7 +317,7 @@ walkoptree(pTHX_ SV *opsv, char *method) if (!SvROK(opsv)) croak("opsv is not a reference"); opsv = sv_mortalcopy(opsv); - o = (OP*)SvIV((SV*)SvRV(opsv)); + o = (OP*)PTR_CAST SvIV((SV*)SvRV(opsv)); if (walkoptree_debug) { PUSHMARK(sp); XPUSHs(opsv); @@ -332,7 +332,7 @@ walkoptree(pTHX_ SV *opsv, char *method) OP *kid; for (kid = ((UNOP*)o)->op_first; kid; kid = kid->op_sibling) { /* Use the same opsv. Rely on methods not to mess it up. */ - sv_setiv(newSVrv(opsv, cc_opclassname(aTHX_ kid)), (IV)kid); + sv_setiv(newSVrv(opsv, cc_opclassname(aTHX_ kid)), (IV)PTR_CAST kid); walkoptree(aTHX_ opsv, method); } } @@ -437,7 +437,7 @@ walkoptree_debug(...) OUTPUT: RETVAL -#define address(sv) (IV)sv +#define address(sv) (IV)PTR_CAST sv IV address(sv) @@ -647,10 +647,10 @@ PMOP_pmreplroot(o) if (o->op_type == OP_PUSHRE) { sv_setiv(newSVrv(ST(0), root ? svclassnames[SvTYPE((SV*)root)] : "B::SV"), - (IV)root); + (IV)PTR_CAST root); } else { - sv_setiv(newSVrv(ST(0), cc_opclassname(aTHX_ root)), (IV)root); + sv_setiv(newSVrv(ST(0), cc_opclassname(aTHX_ root)), (IV)PTR_CAST root); } B::OP @@ -814,7 +814,11 @@ packiv(sv) * reach this code anyway (unless sizeof(IV) > 8 but then * everything else breaks too so I'm not fussed at the moment). */ - wp[0] = htonl(((U32)iv) >> (sizeof(IV)*4)); +#ifdef UV_IS_QUAD + wp[0] = htonl(((UV)iv) >> (sizeof(UV)*4)); +#else + wp[0] = htonl(((U32)iv) >> (sizeof(UV)*4)); +#endif wp[1] = htonl(iv & 0xffffffff); ST(0) = sv_2mortal(newSVpvn((char *)wp, 8)); } else { @@ -1149,7 +1153,7 @@ void CvXSUB(cv) B::CV cv CODE: - ST(0) = sv_2mortal(newSViv((IV)CvXSUB(cv))); + ST(0) = sv_2mortal(newSViv((IV)PTR_CAST CvXSUB(cv))); void diff --git a/ext/B/typemap b/ext/B/typemap index 948fdcd..5f6af0f 100644 --- a/ext/B/typemap +++ b/ext/B/typemap @@ -35,7 +35,7 @@ INPUT T_OP_OBJ if (SvROK($arg)) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = ($type) tmp; + $var = ($type)PTR_CAST tmp; } else croak(\"$var is not a reference\") @@ -43,7 +43,7 @@ T_OP_OBJ T_SV_OBJ if (SvROK($arg)) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = ($type) tmp; + $var = ($type)PTR_CAST tmp; } else croak(\"$var is not a reference\") @@ -51,18 +51,18 @@ T_SV_OBJ T_MG_OBJ if (SvROK($arg)) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = ($type) tmp; + $var = ($type)PTR_CAST tmp; } else croak(\"$var is not a reference\") OUTPUT T_OP_OBJ - sv_setiv(newSVrv($arg, cc_opclassname(aTHX_ (OP*)$var)), (IV)$var); + sv_setiv(newSVrv($arg, cc_opclassname(aTHX_ (OP*)$var)), (IV)PTR_CAST $var); T_SV_OBJ make_sv_object(aTHX_ ($arg), (SV*)($var)); T_MG_OBJ - sv_setiv(newSVrv($arg, "B::MAGIC"), (IV)$var); + sv_setiv(newSVrv($arg, "B::MAGIC"), (IV)PTR_CAST $var); diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h index 1dda7e6..5ca0d1a 100644 --- a/ext/ByteLoader/bytecode.h +++ b/ext/ByteLoader/bytecode.h @@ -43,7 +43,7 @@ typedef IV IV64; BGET_U32(hi); \ BGET_U32(lo); \ if (sizeof(IV) == 8) \ - arg = (IV) (hi << (sizeof(IV)*4) | lo); \ + arg = ((IV)hi << (sizeof(IV)*4) | (IV)lo); \ else if (((I32)hi == -1 && (I32)lo < 0) \ || ((I32)hi == 0 && (I32)lo >= 0)) { \ arg = (I32)lo; \ diff --git a/ext/Devel/DProf/DProf.xs b/ext/Devel/DProf/DProf.xs index e5b7788..62a0c9e 100644 --- a/ext/Devel/DProf/DProf.xs +++ b/ext/Devel/DProf/DProf.xs @@ -292,7 +292,7 @@ prof_mark( opcode ptype ) static U32 lastid; CV *cv; - cv = (CV*)SvIVX(Sub); + cv = (CV*)PTR_CAST SvIVX(Sub); svp = hv_fetch(cv_hash, (char*)&cv, sizeof(CV*), TRUE); if (!SvOK(*svp)) { GV *gv = CvGV(cv); @@ -568,7 +568,7 @@ XS(XS_DB_sub) PUSHMARK( ORIGMARK ); #ifdef G_NODEBUG - perl_call_sv( (SV*)SvIV(Sub), GIMME | G_NODEBUG); + perl_call_sv( (SV*)PTR_CAST SvIV(Sub), GIMME | G_NODEBUG); #else curstash = debstash; /* To disable debugging of perl_call_sv */ #ifdef PERLDBf_NONAME diff --git a/ext/DynaLoader/dl_dlopen.xs b/ext/DynaLoader/dl_dlopen.xs index a317208..a4dcfb4 100644 --- a/ext/DynaLoader/dl_dlopen.xs +++ b/ext/DynaLoader/dl_dlopen.xs @@ -166,7 +166,7 @@ dl_load_file(filename, flags=0) if (RETVAL == NULL) SaveError(aTHX_ "%s",dlerror()) ; else - sv_setiv( ST(0), (IV)RETVAL); + sv_setiv( ST(0), (IV)PTR_CAST RETVAL); void * @@ -187,7 +187,7 @@ dl_find_symbol(libhandle, symbolname) if (RETVAL == NULL) SaveError(aTHX_ "%s",dlerror()) ; else - sv_setiv( ST(0), (IV)RETVAL); + sv_setiv( ST(0), (IV)PTR_CAST RETVAL); void diff --git a/ext/ODBM_File/ODBM_File.xs b/ext/ODBM_File/ODBM_File.xs index 7601c34..bb2eb47 100644 --- a/ext/ODBM_File/ODBM_File.xs +++ b/ext/ODBM_File/ODBM_File.xs @@ -111,7 +111,7 @@ odbm_TIEHASH(dbtype, filename, flags, mode) Zero(RETVAL, 1, ODBM_File_type) ; RETVAL->dbp = dbp ; ST(0) = sv_mortalcopy(&PL_sv_undef); - sv_setptrobj(ST(0), RETVAL, dbtype); + sv_setptrobj(ST(0), PTR_CAST RETVAL, dbtype); } void diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index cc3f0c1..0f09aac 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -3246,7 +3246,7 @@ sigaction(sig, action, oldaction = 0) } else { New(0, sigset, 1, sigset_t); - sv_setptrobj(*svp, sigset, "POSIX::SigSet"); + sv_setptrobj(*svp, PTR_CAST sigset, "POSIX::SigSet"); } *sigset = oact.sa_mask; @@ -3274,7 +3274,7 @@ INIT: } else if (sv_derived_from(ST(2), "POSIX::SigSet")) { IV tmp = SvIV((SV*)SvRV(ST(2))); - oldsigset = (POSIX__SigSet) tmp; + oldsigset = (POSIX__SigSet)PTR_CAST tmp; } else { New(0, oldsigset, 1, sigset_t); @@ -3455,10 +3455,12 @@ strtol(str, base = 0) char *unparsed; PPCODE: num = strtol(str, &unparsed, base); - if (num >= IV_MIN && num <= IV_MAX) - PUSHs(sv_2mortal(newSViv((IV)num))); - else +#if IVSIZE <= LONGSIZE + if (num < IV_MIN || num > IV_MAX) PUSHs(sv_2mortal(newSVnv((double)num))); + else +#endif + PUSHs(sv_2mortal(newSViv((IV)num))); if (GIMME == G_ARRAY) { EXTEND(SP, 1); if (unparsed) diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap index 65970cf..a332024 100644 --- a/lib/ExtUtils/typemap +++ b/lib/ExtUtils/typemap @@ -1,4 +1,4 @@ -# $Header$ +# $Header: /home/rmb1/misc/perl/build/perl5.005_60/lib/ExtUtils/../../../RCS/perl5.005_61/lib/ExtUtils/typemap,v 1.2 1999/09/07 10:05:21 rmb1 Exp $ # basic C types int T_IV unsigned T_UV @@ -107,11 +107,11 @@ T_DOUBLE T_PV $var = ($type)SvPV($arg,PL_na) T_PTR - $var = ($type)SvIV($arg) + $var = ($type)PTR_CAST SvIV($arg) T_PTRREF if (SvROK($arg)) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = ($type) tmp; + $var = ($type)PTR_CAST tmp; } else croak(\"$var is not a reference\") @@ -132,7 +132,7 @@ T_REF_IV_PTR T_PTROBJ if (sv_derived_from($arg, \"${ntype}\")) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = ($type) tmp; + $var = ($type)PTR_CAST tmp; } else croak(\"$var is not of type ${ntype}\") @@ -147,14 +147,14 @@ T_PTRDESC T_REFREF if (SvROK($arg)) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = *($type) tmp; + $var = *($type)PTR_CAST tmp; } else croak(\"$var is not a reference\") T_REFOBJ if (sv_isa($arg, \"${ntype}\")) { IV tmp = SvIV((SV*)SvRV($arg)); - $var = *($type) tmp; + $var = *($type)PTR_CAST tmp; } else croak(\"$var is not of type ${ntype}\") diff --git a/malloc.c b/malloc.c index a3344ae..908d7a7 100644 --- a/malloc.c +++ b/malloc.c @@ -516,9 +516,9 @@ static u_short buck_size[MAX_BUCKET_BY_TABLE + 1] = # define MAX_PACKED (MAX_PACKED_POW2 * BUCKETS_PER_POW2 + BUCKET_POW2_SHIFT) # define MAX_POW2_ALGO ((1<<(MAX_PACKED_POW2 + 1)) - M_OVERHEAD) # define TWOK_MASK ((1<> \ @@ -781,7 +781,7 @@ emergency_sbrk(MEM_SIZE size) /* Got it, now detach SvPV: */ pv = SvPV(sv, n_a); /* Check alignment: */ - if (((UV)(pv - sizeof(union overhead))) & (NEEDED_ALIGNMENT - 1)) { + if (((UV)PTR_CAST (pv - sizeof(union overhead))) & (NEEDED_ALIGNMENT - 1)) { PerlIO_puts(PerlIO_stderr(),"Bad alignment of $^M!\n"); return (char *)-1; /* die die die */ } @@ -924,7 +924,7 @@ Perl_malloc(register size_t nbytes) /* remove from linked list */ #if defined(RCHECK) - if (((UV)p) & (MEM_ALIGNBYTES - 1)) + if (((UV)PTR_CAST p) & (MEM_ALIGNBYTES - 1)) PerlIO_printf(PerlIO_stderr(), "Corrupt malloc ptr 0x%lx at 0x%lx\n", (unsigned long)*((int*)p),(unsigned long)p); #endif @@ -1121,8 +1121,8 @@ getpages(int needed, int *nblksp, int bucket) # ifndef I286 /* The sbrk(0) call on the I286 always returns the next segment */ /* WANTED_ALIGNMENT may be more than NEEDED_ALIGNMENT, but this may improve performance of memory access. */ - if ((UV)cp & (WANTED_ALIGNMENT - 1)) { /* Not aligned. */ - slack = WANTED_ALIGNMENT - ((UV)cp & (WANTED_ALIGNMENT - 1)); + if ((UV)PTR_CAST cp & (WANTED_ALIGNMENT - 1)) { /* Not aligned. */ + slack = WANTED_ALIGNMENT - ((UV)PTR_CAST cp & (WANTED_ALIGNMENT - 1)); add += slack; } # endif @@ -1183,16 +1183,16 @@ getpages(int needed, int *nblksp, int bucket) */ # if NEEDED_ALIGNMENT > MEM_ALIGNBYTES - if ((UV)ovp & (NEEDED_ALIGNMENT - 1)) + if ((UV)PTR_CAST ovp & (NEEDED_ALIGNMENT - 1)) fatalcroak("Misalignment of sbrk()\n"); else # endif #ifndef I286 /* Again, this should always be ok on an 80286 */ - if ((UV)ovp & (MEM_ALIGNBYTES - 1)) { + if ((UV)PTR_CAST ovp & (MEM_ALIGNBYTES - 1)) { DEBUG_m(PerlIO_printf(Perl_debug_log, "fixing sbrk(): %d bytes off machine alignement\n", - (int)((UV)ovp & (MEM_ALIGNBYTES - 1)))); - ovp = (union overhead *)(((UV)ovp + MEM_ALIGNBYTES) & + (int)((UV)PTR_CAST ovp & (MEM_ALIGNBYTES - 1)))); + ovp = (union overhead *)PTR_CAST (((UV)PTR_CAST ovp + MEM_ALIGNBYTES) & (MEM_ALIGNBYTES - 1)); (*nblksp)--; # if defined(DEBUGGING_MSTATS) diff --git a/perl.h b/perl.h index 64b349a..8d0a7bd 100644 --- a/perl.h +++ b/perl.h @@ -1044,8 +1044,20 @@ Free_t Perl_mfree (Malloc_t where); # define IVSIZE LONGSIZE #endif #define IV_DIG (BIT_DIGITS(IVSIZE * 8)) -#define UV_DIG (BIT_DIGITS(IVSIZE * 8)) +#define UV_DIG (BIT_DIGITS(UVSIZE * 8)) +#if (IVSIZE > PTRSIZE) || (UVSIZE > PTRSIZE) +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define PTR_CAST (PTRV) +#else +# define PTRV UV +# define PTR_CAST +#endif + #ifdef USE_LONG_DOUBLE # if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE) # define LDoub_t long double diff --git a/pp.c b/pp.c index 7f4cdc4..c98206a 100644 --- a/pp.c +++ b/pp.c @@ -1778,9 +1778,9 @@ S_seed(pTHX) # endif #endif u += SEED_C3 * (U32)getpid(); - u += SEED_C4 * (U32)(UV)PL_stack_sp; + u += SEED_C4 * (U32)(UV)PTR_CAST PL_stack_sp; #ifndef PLAN9 /* XXX Plan9 assembler chokes on this; fix needed */ - u += SEED_C5 * (U32)(UV)&when; + u += SEED_C5 * (U32)(UV)PTR_CAST &when; #endif return u; } diff --git a/pp_ctl.c b/pp_ctl.c index 8e788e6..7a65ec0 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -223,12 +223,12 @@ Perl_rxres_save(pTHX_ void **rsp, REGEXP *rx) *rsp = (void*)p; } - *p++ = (UV)(RX_MATCH_COPIED(rx) ? rx->subbeg : Nullch); + *p++ = (UV)PTR_CAST (RX_MATCH_COPIED(rx) ? rx->subbeg : Nullch); RX_MATCH_COPIED_off(rx); *p++ = rx->nparens; - *p++ = (UV)rx->subbeg; + *p++ = (UV)PTR_CAST rx->subbeg; *p++ = (UV)rx->sublen; for (i = 0; i <= rx->nparens; ++i) { *p++ = (UV)rx->startp[i]; @@ -249,7 +249,7 @@ Perl_rxres_restore(pTHX_ void **rsp, REGEXP *rx) rx->nparens = *p++; - rx->subbeg = (char*)(*p++); + rx->subbeg = (char*)PTR_CAST (*p++); rx->sublen = (I32)(*p++); for (i = 0; i <= rx->nparens; ++i) { rx->startp[i] = (I32)(*p++); @@ -263,7 +263,7 @@ Perl_rxres_free(pTHX_ void **rsp) UV *p = (UV*)*rsp; if (p) { - Safefree((char*)(*p)); + Safefree((char*)PTR_CAST (*p)); Safefree(p); *rsp = Null(void*); } @@ -2199,7 +2199,7 @@ PP(pp_goto) CV *gotocv; if (PERLDB_SUB_NN) { - SvIVX(sv) = (IV)cv; /* Already upgraded, saved */ + SvIVX(sv) = (IV)PTR_CAST cv; /* Already upgraded, saved */ } else { save_item(sv); gv_efullname3(sv, CvGV(cv), Nullch); diff --git a/pp_hot.c b/pp_hot.c index bb034e5..7be8607 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1588,7 +1588,7 @@ PP(pp_iter) } LvTARG(lv) = SvREFCNT_inc(av); LvTARGOFF(lv) = cx->blk_loop.iterix; - LvTARGLEN(lv) = (UV) -1; + LvTARGLEN(lv) = (STRLEN)UV_MAX; sv = (SV*)lv; } @@ -2112,7 +2112,7 @@ S_get_db_sub(pTHX_ SV **svp, CV *cv) SvUPGRADE(dbsv, SVt_PVIV); SvIOK_on(dbsv); SAVEIV(SvIVX(dbsv)); - SvIVX(dbsv) = (IV)cv; /* Do it the quickest way */ + SvIVX(dbsv) = (IV)PTR_CAST cv; /* Do it the quickest way */ } if (CvXSUB(cv)) diff --git a/pp_sys.c b/pp_sys.c index baf59ed..5271a86 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1898,7 +1898,7 @@ PP(pp_ioctl) } else { retval = SvIV(argsv); - s = (char*)retval; /* ouch */ + s = (char*)PTR_CAST retval; /* ouch */ } TAINT_PROPER(optype == OP_IOCTL ? "ioctl" : "fcntl"); diff --git a/sv.c b/sv.c index 1f0d1a7..956f3b9 100644 --- a/sv.c +++ b/sv.c @@ -612,8 +612,8 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 mt) pv = (char*)SvRV(sv); cur = 0; len = 0; - iv = (IV)pv; - nv = (NV)(unsigned long)pv; + iv = (IV)PTR_CAST pv; + nv = (NV)(PTRV)pv; del_XRV(SvANY(sv)); magic = 0; stash = 0; @@ -1077,7 +1077,7 @@ Perl_sv_2iv(pTHX_ register SV *sv) SV* tmpstr; if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv, numer))) return SvIV(tmpstr); - return (IV)SvRV(sv); + return (IV)PTR_CAST SvRV(sv); } if (SvREADONLY(sv) && !SvOK(sv)) { dTHR; @@ -1113,7 +1113,7 @@ Perl_sv_2iv(pTHX_ register SV *sv) #ifdef IV_IS_QUAD DEBUG_c(PerlIO_printf(Perl_debug_log, "0x%" PERL_PRIx64 " 2iv(%" PERL_PRIu64 " => %" PERL_PRId64 ") (as unsigned)\n", - (UV)sv, + (UV)PTR_CAST sv, (UV)SvUVX(sv), (IV)SvUVX(sv))); #else DEBUG_c(PerlIO_printf(Perl_debug_log, @@ -1222,7 +1222,7 @@ Perl_sv_2uv(pTHX_ register SV *sv) SV* tmpstr; if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv, numer))) return SvUV(tmpstr); - return (UV)SvRV(sv); + return (UV)PTR_CAST SvRV(sv); } if (SvREADONLY(sv) && !SvOK(sv)) { dTHR; @@ -1393,7 +1393,7 @@ Perl_sv_2nv(pTHX_ register SV *sv) SV* tmpstr; if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,numer))) return SvNV(tmpstr); - return (NV)(unsigned long)SvRV(sv); + return (NV)(PTRV)SvRV(sv); } if (SvREADONLY(sv) && !SvOK(sv)) { dTHR; @@ -1777,7 +1777,7 @@ Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp) else sv_setpv(tsv, s); #ifdef IV_IS_QUAD - Perl_sv_catpvf(aTHX_ tsv, "(0x%" PERL_PRIx64")", (UV)sv); + Perl_sv_catpvf(aTHX_ tsv, "(0x%" PERL_PRIx64")", (UV)PTR_CAST sv); #else Perl_sv_catpvf(aTHX_ tsv, "(0x%lx)", (unsigned long)sv); #endif @@ -3691,7 +3691,7 @@ Perl_sv_inc(pTHX_ register SV *sv) IV i; if (SvAMAGIC(sv) && AMG_CALLun(sv,inc)) return; - i = (IV)SvRV(sv); + i = (IV)PTR_CAST SvRV(sv); sv_unref(sv); sv_setiv(sv, i); } @@ -3791,7 +3791,7 @@ Perl_sv_dec(pTHX_ register SV *sv) IV i; if (SvAMAGIC(sv) && AMG_CALLun(sv,dec)) return; - i = (IV)SvRV(sv); + i = (IV)PTR_CAST SvRV(sv); sv_unref(sv); sv_setiv(sv, i); } @@ -4395,7 +4395,7 @@ Perl_sv_setref_pv(pTHX_ SV *rv, const char *classname, void *pv) SvSETMAGIC(rv); } else - sv_setiv(newSVrv(rv,classname), (IV)pv); + sv_setiv(newSVrv(rv,classname), (IV)PTR_CAST pv); return rv; } @@ -4898,9 +4898,9 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV case 'p': if (args) - uv = (UV)va_arg(*args, void*); + uv = (UV)PTR_CAST va_arg(*args, void*); else - uv = (svix < svmax) ? (UV)svargs[svix++] : 0; + uv = (svix < svmax) ? (UV)PTR_CAST svargs[svix++] : 0; base = 16; goto integer;