else
{
IV i = SvIV(astr);
- a = (char *)PTR_CAST i; /* ouch */
+ a = INT2PTR(char *,i); /* ouch */
}
SETERRNO(0,0);
switch (optype)
#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)PTR_CAST SvANY(sv), (UV)PTR_CAST sv,
+ PTR2UV(SvANY(sv)), PTR2UV(sv),
PL_dumpindent*level, "", (IV)SvREFCNT(sv),
PL_dumpindent*level, "");
#else
}
if (SvROK(sv)) {
#ifdef IV_IS_QUAD
- Perl_dump_indent(aTHX_ level, file, " RV = 0x%" PERL_PRIx64 "\n", (IV)PTR_CAST SvRV(sv));
+ Perl_dump_indent(aTHX_ level, file, " RV = 0x%" PERL_PRIx64 "\n", PTR2IV(SvRV(sv)));
#else
Perl_dump_indent(aTHX_ level, file, " RV = 0x%lx\n", (long)SvRV(sv));
#endif
if (type <= SVt_PVLV) {
if (SvPVX(sv)) {
#ifdef IV_IS_QUAD
- Perl_dump_indent(aTHX_ level, file," PV = 0x%" PERL_PRIx64 " ", (IV)PTR_CAST SvPVX(sv));
+ Perl_dump_indent(aTHX_ level, file," PV = 0x%" PERL_PRIx64 " ", PTR2IV(SvPVX(sv)));
#else
Perl_dump_indent(aTHX_ level, file," PV = 0x%lx ", (long)SvPVX(sv));
#endif
#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)PTR_CAST LvTARG(sv));
+ Perl_dump_indent(aTHX_ level, file, " TARG = 0x%" PERL_PRIx64 "\n", PTR2IV(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));
break;
case SVt_PVAV:
#ifdef IV_IS_QUAD
- Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64 , (IV)PTR_CAST AvARRAY(sv));
+ Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64 , PTR2IV(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)PTR_CAST AvALLOC(sv));
+ Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%" PERL_PRIx64 "\n", PTR2IV(AvALLOC(sv)));
#else
Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%lx\n", (long)AvALLOC(sv));
#endif
#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)PTR_CAST AvARYLEN(sv));
+ Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%" PERL_PRIx64 "\n", PTR2IV(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));
break;
case SVt_PVHV:
#ifdef IV_IS_QUAD
- Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64,(IV)PTR_CAST HvARRAY(sv));
+ Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%" PERL_PRIx64,PTR2IV(HvARRAY(sv)));
#else
Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%lx",(long)HvARRAY(sv));
#endif
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)PTR_CAST HvEITER(sv));
+ Perl_dump_indent(aTHX_ level, file, " EITER = 0x%" PERL_PRIx64 "\n",PTR2IV(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));
#endif
if (HvPMROOT(sv))
#ifdef IV_IS_QUAD
- Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%" PERL_PRIx64 "\n",(IV)PTR_CAST HvPMROOT(sv));
+ Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%" PERL_PRIx64 "\n",PTR2IV(HvPMROOT(sv)));
#else
Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%lx\n",(long)HvPMROOT(sv));
#endif
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)PTR_CAST CvXSUB(sv));
+ Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%" PERL_PRIx64 "\n", PTR2IV(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));
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)PTR_CAST CvPADLIST(sv));
+ Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%" PERL_PRIx64 "\n", PTR2IV(CvPADLIST(sv)));
#else
Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%lx\n", (long)CvPADLIST(sv));
#endif
CV *outside = CvOUTSIDE(sv);
#ifdef IV_IS_QUAD
Perl_dump_indent(aTHX_ level, file, " OUTSIDE = 0x%" PERL_PRIx64 " (%s)\n",
- (IV)PTR_CAST outside,
+ PTR2IV(outside),
(!outside ? "null"
: CvANON(outside) ? "ANON"
: (outside == PL_main_cv) ? "MAIN"
#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)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, " GP = 0x%" PERL_PRIx64 "\n", PTR2IV(GvGP(sv)));
+ Perl_dump_indent(aTHX_ level, file, " SV = 0x%" PERL_PRIx64 "\n", PTR2IV(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)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, " IO = 0x%" PERL_PRIx64 "\n", PTR2IV(GvIOp(sv)));
+ Perl_dump_indent(aTHX_ level, file, " FORM = 0x%" PERL_PRIx64 " \n", PTR2IV(GvFORM(sv)));
+ Perl_dump_indent(aTHX_ level, file, " AV = 0x%" PERL_PRIx64 "\n", PTR2IV(GvAV(sv)));
+ Perl_dump_indent(aTHX_ level, file, " HV = 0x%" PERL_PRIx64 "\n", PTR2IV(GvHV(sv)));
+ Perl_dump_indent(aTHX_ level, file, " CV = 0x%" PERL_PRIx64 "\n", PTR2IV(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));
break;
case SVt_PVIO:
#ifdef IV_IS_QUAD
- 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, " IFP = 0x%" PERL_PRIx64 "\n", PTR2IV(IoIFP(sv)));
+ Perl_dump_indent(aTHX_ level, file, " OFP = 0x%" PERL_PRIx64 "\n", PTR2IV(IoOFP(sv)));
+ Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%" PERL_PRIx64 "\n", PTR2IV(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));
}
if (!type) {
type = svclassnames[SvTYPE(sv)];
- iv = (IV)PTR_CAST sv;
+ iv = PTR2IV(sv);
}
sv_setiv(newSVrv(arg, type), iv);
return arg;
static SV *
make_mg_object(pTHX_ SV *arg, MAGIC *mg)
{
- sv_setiv(newSVrv(arg, "B::MAGIC"), (IV)PTR_CAST mg);
+ sv_setiv(newSVrv(arg, "B::MAGIC"), PTR2IV(mg));
return arg;
}
if (!SvROK(opsv))
croak("opsv is not a reference");
opsv = sv_mortalcopy(opsv);
- o = (OP*)PTR_CAST SvIV((SV*)SvRV(opsv));
+ o = INT2PTR(OP*,SvIV((SV*)SvRV(opsv)));
if (walkoptree_debug) {
PUSHMARK(sp);
XPUSHs(opsv);
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)PTR_CAST kid);
+ sv_setiv(newSVrv(opsv, cc_opclassname(aTHX_ kid)), PTR2IV(kid));
walkoptree(aTHX_ opsv, method);
}
}
OUTPUT:
RETVAL
-#define address(sv) (IV)PTR_CAST sv
+#define address(sv) PTR2IV(sv)
IV
address(sv)
if (o->op_type == OP_PUSHRE) {
sv_setiv(newSVrv(ST(0), root ?
svclassnames[SvTYPE((SV*)root)] : "B::SV"),
- (IV)PTR_CAST root);
+ PTR2IV(root));
}
else {
- sv_setiv(newSVrv(ST(0), cc_opclassname(aTHX_ root)), (IV)PTR_CAST root);
+ sv_setiv(newSVrv(ST(0), cc_opclassname(aTHX_ root)), PTR2IV(root));
}
B::OP
CvXSUB(cv)
B::CV cv
CODE:
- ST(0) = sv_2mortal(newSViv((IV)PTR_CAST CvXSUB(cv)));
+ ST(0) = sv_2mortal(newSViv(PTR2IV(CvXSUB(cv))));
void
T_OP_OBJ
if (SvROK($arg)) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type)PTR_CAST tmp;
+ $var = INT2PTR($type,tmp);
}
else
croak(\"$var is not a reference\")
T_SV_OBJ
if (SvROK($arg)) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type)PTR_CAST tmp;
+ $var = INT2PTR($type,tmp);
}
else
croak(\"$var is not a reference\")
T_MG_OBJ
if (SvROK($arg)) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type)PTR_CAST tmp;
+ $var = INT2PTR($type,tmp);
}
else
croak(\"$var is not a reference\")
OUTPUT
T_OP_OBJ
- sv_setiv(newSVrv($arg, cc_opclassname(aTHX_ (OP*)$var)), (IV)PTR_CAST $var);
+ sv_setiv(newSVrv($arg, cc_opclassname(aTHX_ (OP*)$var)), PTR2IV($var));
T_SV_OBJ
make_sv_object(aTHX_ ($arg), (SV*)($var));
T_MG_OBJ
- sv_setiv(newSVrv($arg, "B::MAGIC"), (IV)PTR_CAST $var);
+ sv_setiv(newSVrv($arg, "B::MAGIC"), PTR2IV($var));
static U32 lastid;
CV *cv;
- cv = (CV*)PTR_CAST SvIVX(Sub);
+ cv = INT2PTR(CV*,SvIVX(Sub));
svp = hv_fetch(cv_hash, (char*)&cv, sizeof(CV*), TRUE);
if (!SvOK(*svp)) {
GV *gv = CvGV(cv);
PUSHMARK( ORIGMARK );
#ifdef G_NODEBUG
- perl_call_sv( (SV*)PTR_CAST SvIV(Sub), GIMME | G_NODEBUG);
+ perl_call_sv( INT2PTR(SV*,SvIV(Sub)), GIMME | G_NODEBUG);
#else
curstash = debstash; /* To disable debugging of perl_call_sv */
#ifdef PERLDBf_NONAME
if (RETVAL == NULL)
SaveError(aTHX_ "%s",dlerror()) ;
else
- sv_setiv( ST(0), (IV)PTR_CAST RETVAL);
+ sv_setiv( ST(0), PTR2IV(RETVAL));
void *
if (RETVAL == NULL)
SaveError(aTHX_ "%s",dlerror()) ;
else
- sv_setiv( ST(0), (IV)PTR_CAST RETVAL);
+ sv_setiv( ST(0), PTR2IV(RETVAL));
void
Zero(RETVAL, 1, ODBM_File_type) ;
RETVAL->dbp = dbp ;
ST(0) = sv_mortalcopy(&PL_sv_undef);
- sv_setptrobj(ST(0), PTR_CAST RETVAL, dbtype);
+ sv_setptrobj(ST(0), RETVAL, dbtype);
}
void
}
else {
New(0, sigset, 1, sigset_t);
- sv_setptrobj(*svp, PTR_CAST sigset, "POSIX::SigSet");
+ sv_setptrobj(*svp, sigset, "POSIX::SigSet");
}
*sigset = oact.sa_mask;
}
else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
IV tmp = SvIV((SV*)SvRV(ST(2)));
- oldsigset = (POSIX__SigSet)PTR_CAST tmp;
+ oldsigset = INT2PTR(POSIX__SigSet,tmp);
}
else {
New(0, oldsigset, 1, sigset_t);
-# $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 $
+# $Header: /home/rmb1/misc/CVS/perl5.005_61/lib/ExtUtils/typemap,v 1.3 1999/09/13 09:46:43 rmb1 Exp $
# basic C types
int T_IV
unsigned T_UV
T_PV
$var = ($type)SvPV($arg,PL_na)
T_PTR
- $var = ($type)PTR_CAST SvIV($arg)
+ $var = INT2PTR($type,SvIV($arg))
T_PTRREF
if (SvROK($arg)) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type)PTR_CAST tmp;
+ $var = INT2PTR($type,tmp);
}
else
croak(\"$var is not a reference\")
T_PTROBJ
if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type)PTR_CAST tmp;
+ $var = INT2PTR($type,tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_REFREF
if (SvROK($arg)) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = *($type)PTR_CAST tmp;
+ $var = *INT2PTR($type,tmp);
}
else
croak(\"$var is not a reference\")
T_REFOBJ
if (sv_isa($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = *($type)PTR_CAST tmp;
+ $var = *INT2PTR($type,tmp);
}
else
croak(\"$var is not of type ${ntype}\")
#define u_char unsigned char
#define u_int unsigned int
-
-#ifdef HAS_QUAD
-# define u_bigint UV /* Needs to eat *void. */
-#else /* needed? */
-# define u_bigint unsigned long /* Needs to eat *void. */
-#endif
-
+/*
+ * I removed the definition of u_bigint which appeared to be u_bigint = UV
+ * u_bigint was only used in TWOK_MASKED and TWOK_SHIFT
+ * where I have used PTR2UV. RMB
+ */
#define u_short unsigned short
/* 286 and atarist like big chunks, which gives too much overhead. */
# 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<<LOG_OF_MIN_ARENA) - 1)
-# define TWOK_MASKED(x) ((u_bigint)PTR_CAST(x) & ~TWOK_MASK)
-# define TWOK_SHIFT(x) ((u_bigint)PTR_CAST(x) & TWOK_MASK)
-# define OV_INDEXp(block) ((u_char*)PTR_CAST(TWOK_MASKED(block)))
+# define TWOK_MASKED(x) (PTR2UV(x) & ~TWOK_MASK)
+# define TWOK_SHIFT(x) (PTR2UV(x) & TWOK_MASK)
+# define OV_INDEXp(block) (INT2PTR(u_char*,TWOK_MASKED(block)))
# define OV_INDEX(block) (*OV_INDEXp(block))
# define OV_MAGIC(block,bucket) (*(OV_INDEXp(block) + \
(TWOK_SHIFT(block)>> \
/* Got it, now detach SvPV: */
pv = SvPV(sv, n_a);
/* Check alignment: */
- if (((UV)PTR_CAST (pv - sizeof(union overhead))) & (NEEDED_ALIGNMENT - 1)) {
+ if ((PTR2UV(pv) - sizeof(union overhead)) & (NEEDED_ALIGNMENT - 1)) {
PerlIO_puts(PerlIO_stderr(),"Bad alignment of $^M!\n");
return (char *)-1; /* die die die */
}
/* remove from linked list */
#if defined(RCHECK)
- if (((UV)PTR_CAST p) & (MEM_ALIGNBYTES - 1))
+ if ((PTR2UV(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
# 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)PTR_CAST cp & (WANTED_ALIGNMENT - 1)) { /* Not aligned. */
- slack = WANTED_ALIGNMENT - ((UV)PTR_CAST cp & (WANTED_ALIGNMENT - 1));
+ if (PTR2UV(cp) & (WANTED_ALIGNMENT - 1)) { /* Not aligned. */
+ slack = WANTED_ALIGNMENT - (PTR2UV(cp) & (WANTED_ALIGNMENT - 1));
add += slack;
}
# endif
*/
# if NEEDED_ALIGNMENT > MEM_ALIGNBYTES
- if ((UV)PTR_CAST ovp & (NEEDED_ALIGNMENT - 1))
+ if (PTR2UV(ovp) & (NEEDED_ALIGNMENT - 1))
fatalcroak("Misalignment of sbrk()\n");
else
# endif
#ifndef I286 /* Again, this should always be ok on an 80286 */
- if ((UV)PTR_CAST ovp & (MEM_ALIGNBYTES - 1)) {
+ if (PTR2UV(ovp) & (MEM_ALIGNBYTES - 1)) {
DEBUG_m(PerlIO_printf(Perl_debug_log,
"fixing sbrk(): %d bytes off machine alignement\n",
- (int)((UV)PTR_CAST ovp & (MEM_ALIGNBYTES - 1))));
- ovp = (union overhead *)PTR_CAST (((UV)PTR_CAST ovp + MEM_ALIGNBYTES) &
+ (int)(PTR2UV(ovp) & (MEM_ALIGNBYTES - 1))));
+ ovp = INT2PTR(union overhead *,(PTR2UV(ovp) + MEM_ALIGNBYTES) &
(MEM_ALIGNBYTES - 1));
(*nblksp)--;
# if defined(DEBUGGING_MSTATS)
# define IVSIZE LONGSIZE
#endif
#define IV_DIG (BIT_DIGITS(IVSIZE * 8))
-#define UV_DIG (BIT_DIGITS(UVSIZE * 8))
-
-#if (IVSIZE > PTRSIZE) || (UVSIZE > PTRSIZE)
+#define UV_DIG (BIT_DIGITS(IVSIZE * 8))
+
++ /*
++ * The macros INT2PTR and NUM2PTR are (despite their names)
++ * bi-directional: they will convert int/float to or from pointers.
++ * However the conversion to int/float are named explicitly:
++ * PTR2IV, PTR2UV, PTR2NV.
++ *
++ * For int conversions we do not need two casts if pointers are
++ * the same size as IV and UV. Otherwise we need an explicit
++ * cast (PTRV) to avoid compiler warnings.
++ */
+#if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
+# define PTRV UV
+# define INT2PTR(any,d) (any)(d)
+#else
# if PTRSIZE == LONGSIZE
-# define PTRV unsigned long
+# define PTRV unsigned long
# else
-# define PTRV unsigned
+# define PTRV unsigned
# endif
-# define PTR_CAST (PTRV)
-#else
-# define PTRV UV
-# define PTR_CAST
+# define INT2PTR(any,d) (any)(PTRV)(d)
#endif
+#define NUM2PTR(any,d) (any)(PTRV)(d)
+#define PTR2IV(p) INT2PTR(IV,p)
+#define PTR2UV(p) INT2PTR(UV,p)
+#define PTR2NV(p) NUM2PTR(NV,p)
#ifdef USE_LONG_DOUBLE
# if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
# endif
#endif
u += SEED_C3 * (U32)getpid();
- u += SEED_C4 * (U32)(UV)PTR_CAST PL_stack_sp;
+ u += SEED_C4 * (U32)PTR2UV(PL_stack_sp);
#ifndef PLAN9 /* XXX Plan9 assembler chokes on this; fix needed */
- u += SEED_C5 * (U32)(UV)PTR_CAST &when;
+ u += SEED_C5 * (U32)PTR2UV(&when);
#endif
return u;
}
*rsp = (void*)p;
}
- *p++ = (UV)PTR_CAST (RX_MATCH_COPIED(rx) ? rx->subbeg : Nullch);
+ *p++ = PTR2UV(RX_MATCH_COPIED(rx) ? rx->subbeg : Nullch);
RX_MATCH_COPIED_off(rx);
*p++ = rx->nparens;
- *p++ = (UV)PTR_CAST rx->subbeg;
+ *p++ = PTR2UV(rx->subbeg);
*p++ = (UV)rx->sublen;
for (i = 0; i <= rx->nparens; ++i) {
*p++ = (UV)rx->startp[i];
rx->nparens = *p++;
- rx->subbeg = (char*)PTR_CAST (*p++);
+ rx->subbeg = INT2PTR(char*,*p++);
rx->sublen = (I32)(*p++);
for (i = 0; i <= rx->nparens; ++i) {
rx->startp[i] = (I32)(*p++);
UV *p = (UV*)*rsp;
if (p) {
- Safefree((char*)PTR_CAST (*p));
+ Safefree(INT2PTR(char*,*p));
Safefree(p);
*rsp = Null(void*);
}
CV *gotocv;
if (PERLDB_SUB_NN) {
- SvIVX(sv) = (IV)PTR_CAST cv; /* Already upgraded, saved */
+ SvIVX(sv) = PTR2IV(cv); /* Already upgraded, saved */
} else {
save_item(sv);
gv_efullname3(sv, CvGV(cv), Nullch);
SvUPGRADE(dbsv, SVt_PVIV);
SvIOK_on(dbsv);
SAVEIV(SvIVX(dbsv));
- SvIVX(dbsv) = (IV)PTR_CAST cv; /* Do it the quickest way */
+ SvIVX(dbsv) = PTR2IV(cv); /* Do it the quickest way */
}
if (CvXSUB(cv))
}
else {
retval = SvIV(argsv);
- s = (char*)PTR_CAST retval; /* ouch */
+ s = INT2PTR(char*,retval); /* ouch */
}
TAINT_PROPER(optype == OP_IOCTL ? "ioctl" : "fcntl");
pv = (char*)SvRV(sv);
cur = 0;
len = 0;
- iv = (IV)PTR_CAST pv;
- nv = (NV)(PTRV)pv;
+ iv = PTR2IV(pv);
+ nv = PTR2NV(pv);
del_XRV(SvANY(sv));
magic = 0;
stash = 0;
SV* tmpstr;
if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv, numer)))
return SvIV(tmpstr);
- return (IV)PTR_CAST SvRV(sv);
+ return PTR2IV(SvRV(sv));
}
if (SvREADONLY(sv) && !SvOK(sv)) {
dTHR;
#ifdef IV_IS_QUAD
DEBUG_c(PerlIO_printf(Perl_debug_log,
"0x%" PERL_PRIx64 " 2iv(%" PERL_PRIu64 " => %" PERL_PRId64 ") (as unsigned)\n",
- (UV)PTR_CAST sv,
+ PTR2UV(sv),
(UV)SvUVX(sv), (IV)SvUVX(sv)));
#else
DEBUG_c(PerlIO_printf(Perl_debug_log,
SV* tmpstr;
if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv, numer)))
return SvUV(tmpstr);
- return (UV)PTR_CAST SvRV(sv);
+ return PTR2UV(SvRV(sv));
}
if (SvREADONLY(sv) && !SvOK(sv)) {
dTHR;
SV* tmpstr;
if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,numer)))
return SvNV(tmpstr);
- return (NV)(PTRV)SvRV(sv);
+ return PTR2NV(SvRV(sv));
}
if (SvREADONLY(sv) && !SvOK(sv)) {
dTHR;
else
sv_setpv(tsv, s);
#ifdef IV_IS_QUAD
- Perl_sv_catpvf(aTHX_ tsv, "(0x%" PERL_PRIx64")", (UV)PTR_CAST sv);
+ Perl_sv_catpvf(aTHX_ tsv, "(0x%" PERL_PRIx64")", PTR2UV(sv));
#else
Perl_sv_catpvf(aTHX_ tsv, "(0x%lx)", (unsigned long)sv);
#endif
IV i;
if (SvAMAGIC(sv) && AMG_CALLun(sv,inc))
return;
- i = (IV)PTR_CAST SvRV(sv);
+ i = PTR2IV(SvRV(sv));
sv_unref(sv);
sv_setiv(sv, i);
}
IV i;
if (SvAMAGIC(sv) && AMG_CALLun(sv,dec))
return;
- i = (IV)PTR_CAST SvRV(sv);
+ i = PTR2IV(SvRV(sv));
sv_unref(sv);
sv_setiv(sv, i);
}
SvSETMAGIC(rv);
}
else
- sv_setiv(newSVrv(rv,classname), (IV)PTR_CAST pv);
+ sv_setiv(newSVrv(rv,classname), PTR2IV(pv));
return rv;
}
case 'p':
if (args)
- uv = (UV)PTR_CAST va_arg(*args, void*);
+ uv = PTR2UV(va_arg(*args, void*));
else
- uv = (svix < svmax) ? (UV)PTR_CAST svargs[svix++] : 0;
+ uv = (svix < svmax) ? PTR2UV(svargs[svix++]) : 0;
base = 16;
goto integer;