From: Jarkko Hietaniemi Date: Wed, 11 Aug 1999 12:25:59 +0000 (+0000) Subject: Unapply an experimental patch that accidentally escaped X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=41af67ece9e9160bd6c5f33ad5ae5d493a869b60;p=p5sagit%2Fp5-mst-13.2.git Unapply an experimental patch that accidentally escaped from the lab by piggybacking with the change #3955. p4raw-link: @3955 on //depot/cfgperl: d28f7c377ae191ca53d9157f124642cf323614a0 p4raw-id: //depot/cfgperl@3957 --- diff --git a/pp.c b/pp.c index 3cc9759..8a0f0f7 100644 --- a/pp.c +++ b/pp.c @@ -28,6 +28,37 @@ static double UV_MAX_cxux = ((double)UV_MAX); #endif /* + * Types used in bitwise operations. + * + * Normally we'd just use IV and UV. However, some hardware and + * software combinations (e.g. Alpha and current OSF/1) don't have a + * floating-point type to use for NV that has adequate bits to fully + * hold an IV/UV. (In other words, sizeof(long) == sizeof(double).) + * + * It just so happens that "int" is the right size almost everywhere. + */ +typedef int IBW; +typedef unsigned UBW; + +/* + * Mask used after bitwise operations. + * + * There is at least one realm (Cray word machines) that doesn't + * have an integral type (except char) small enough to be represented + * in a double without loss; that is, it has no 32-bit type. + */ +#if LONGSIZE > 4 && defined(_CRAY) && !defined(_CRAYMPP) +# define BW_BITS 32 +# define BW_MASK ((1 << BW_BITS) - 1) +# define BW_SIGN (1 << (BW_BITS - 1)) +# define BWi(i) (((i) & BW_SIGN) ? ((i) | ~BW_MASK) : ((i) & BW_MASK)) +# define BWu(u) ((u) & BW_MASK) +#else +# define BWi(i) (i) +# define BWu(u) (u) +#endif + +/* * Offset for integer pack/unpack. * * On architectures where I16 and I32 aren't really 16 and 32 bits, @@ -900,7 +931,6 @@ PP(pp_pow) PP(pp_multiply) { djSP; dATARGET; tryAMAGICbin(mult,opASSIGN); - tryIVIVbin(*); { dPOPTOPnnrl; SETn( left * right ); @@ -911,16 +941,6 @@ PP(pp_multiply) PP(pp_divide) { djSP; dATARGET; tryAMAGICbin(div,opASSIGN); - if (TOPIOKbin) { - dPOPTOPiirl_ul; - if (right == 0) - DIE(aTHX_ "Illegal division by zero"); - if ((left % right) && !(PL_op->op_private & HINT_INTEGER)) - SETn( (NV)left / (NV)right ); - else - SETi( left / right ); - RETURN; - } { dPOPPOPnnrl; NV value; @@ -1100,7 +1120,6 @@ PP(pp_repeat) PP(pp_subtract) { djSP; dATARGET; tryAMAGICbin(subtr,opASSIGN); - tryIVIVbin(-); { dPOPTOPnnrl_ul; SETn( left - right ); @@ -1112,14 +1131,16 @@ PP(pp_left_shift) { djSP; dATARGET; tryAMAGICbin(lshift,opASSIGN); { - IV shift = POPi; + IBW shift = POPi; if (PL_op->op_private & HINT_INTEGER) { - IV i = TOPi; - SETi(i << shift); + IBW i = TOPi; + i = BWi(i) << shift; + SETi(BWi(i)); } else { - UV u = TOPu; - SETu(u << shift); + UBW u = TOPu; + u <<= shift; + SETu(BWu(u)); } RETURN; } @@ -1129,14 +1150,16 @@ PP(pp_right_shift) { djSP; dATARGET; tryAMAGICbin(rshift,opASSIGN); { - IV shift = POPi; + IBW shift = POPi; if (PL_op->op_private & HINT_INTEGER) { - IV i = TOPi; - SETi(i >> shift); + IBW i = TOPi; + i = BWi(i) >> shift; + SETi(BWi(i)); } else { - UV u = TOPu; - SETu(u >> shift); + UBW u = TOPu; + u >>= shift; + SETu(BWu(u)); } RETURN; } @@ -1306,12 +1329,12 @@ PP(pp_bit_and) dPOPTOPssrl; if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - IV value = SvIV(left) & SvIV(right); - SETi(value); + IBW value = SvIV(left) & SvIV(right); + SETi(BWi(value)); } else { - UV value = SvUV(left) & SvUV(right); - SETu(value); + UBW value = SvUV(left) & SvUV(right); + SETu(BWu(value)); } } else { @@ -1329,12 +1352,12 @@ PP(pp_bit_xor) dPOPTOPssrl; if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - IV value = (USE_LEFT(left) ? SvIV(left) : 0) ^ SvIV(right); - SETi(value); + IBW value = (USE_LEFT(left) ? SvIV(left) : 0) ^ SvIV(right); + SETi(BWi(value)); } else { - UV value = (USE_LEFT(left) ? SvUV(left) : 0) ^ SvUV(right); - SETu(value); + UBW value = (USE_LEFT(left) ? SvUV(left) : 0) ^ SvUV(right); + SETu(BWu(value)); } } else { @@ -1352,12 +1375,12 @@ PP(pp_bit_or) dPOPTOPssrl; if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - IV value = (USE_LEFT(left) ? SvIV(left) : 0) | SvIV(right); - SETi(value); + IBW value = (USE_LEFT(left) ? SvIV(left) : 0) | SvIV(right); + SETi(BWi(value)); } else { - UV value = (USE_LEFT(left) ? SvUV(left) : 0) | SvUV(right); - SETu(value); + UBW value = (USE_LEFT(left) ? SvUV(left) : 0) | SvUV(right); + SETu(BWu(value)); } } else { @@ -1418,12 +1441,12 @@ PP(pp_complement) dTOPss; if (SvNIOKp(sv)) { if (PL_op->op_private & HINT_INTEGER) { - IV value = ~SvIV(sv); - SETi(value); + IBW value = ~SvIV(sv); + SETi(BWi(value)); } else { - UV value = ~SvUV(sv); - SETu(value); + UBW value = ~SvUV(sv); + SETu(BWu(value)); } } else { diff --git a/pp.h b/pp.h index adf3cc9..0eac5a5 100644 --- a/pp.h +++ b/pp.h @@ -143,18 +143,6 @@ #define dPOPTOPiirl dPOPXiirl(TOP) #define dPOPTOPiirl_ul dPOPXiirl_ul(TOP) -#define TOPIOKbin (SvIOK(TOPs) && SvIOK(*(sp-1))) -#define tryIVIVbin(op) \ - if (TOPIOKbin) { \ - dPOPTOPiirl_ul; \ - NV result = (NV)left op (NV)right; \ - if (result >= (NV)IV_MIN && result <= (NV)IV_MAX) \ - SETi( left op right ); \ - else \ - SETn( result ); \ - RETURN; \ - } - #define RETPUSHYES RETURNX(PUSHs(&PL_sv_yes)) #define RETPUSHNO RETURNX(PUSHs(&PL_sv_no)) #define RETPUSHUNDEF RETURNX(PUSHs(&PL_sv_undef)) diff --git a/pp_hot.c b/pp_hot.c index a7ce618..78f07a1 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -248,7 +248,6 @@ PP(pp_or) PP(pp_add) { djSP; dATARGET; tryAMAGICbin(add,opASSIGN); - tryIVIVbin(+); { dPOPTOPnnrl_ul; SETn( left + right );