diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1999-09-04 13:12:14 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-09-04 13:12:14 +0000 |
commit | ea12c2aa2714a53b7f16f1990366373be0ed8933 (patch) | |
tree | a27649c892d3f0e47949f090dd3a13b53b652f96 /pp.c | |
parent | 4564133c4016aec0d37d61c0a6d6d493c6a4db44 (diff) | |
download | perl-ea12c2aa2714a53b7f16f1990366373be0ed8933.tar.gz |
Enable 64-bit clean bit ops.
(Disables the t/op/misc.t substest 3 in 64-bit platforms.)
p4raw-id: //depot/cfgperl@4070
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 111 |
1 files changed, 26 insertions, 85 deletions
@@ -28,37 +28,6 @@ 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, @@ -1131,17 +1100,11 @@ PP(pp_left_shift) { djSP; dATARGET; tryAMAGICbin(lshift,opASSIGN); { - IBW shift = POPi; - if (PL_op->op_private & HINT_INTEGER) { - IBW i = TOPi; - i = BWi(i) << shift; - SETi(BWi(i)); - } - else { - UBW u = TOPu; - u <<= shift; - SETu(BWu(u)); - } + IV shift = POPi; + if (PL_op->op_private & HINT_INTEGER) + SETi(TOPi << shift); + else + SETu(TOPu << shift); RETURN; } } @@ -1150,17 +1113,11 @@ PP(pp_right_shift) { djSP; dATARGET; tryAMAGICbin(rshift,opASSIGN); { - IBW shift = POPi; - if (PL_op->op_private & HINT_INTEGER) { - IBW i = TOPi; - i = BWi(i) >> shift; - SETi(BWi(i)); - } - else { - UBW u = TOPu; - u >>= shift; - SETu(BWu(u)); - } + IV shift = POPi; + if (PL_op->op_private & HINT_INTEGER) + SETi(TOPi >> shift); + else + SETu(TOPu >> shift); RETURN; } } @@ -1328,14 +1285,10 @@ PP(pp_bit_and) { dPOPTOPssrl; if (SvNIOKp(left) || SvNIOKp(right)) { - if (PL_op->op_private & HINT_INTEGER) { - IBW value = SvIV(left) & SvIV(right); - SETi(BWi(value)); - } - else { - UBW value = SvUV(left) & SvUV(right); - SETu(BWu(value)); - } + if (PL_op->op_private & HINT_INTEGER) + SETi( SvIV(left) & SvIV(right) ); + else + SETu( SvUV(left) & SvUV(right) ); } else { do_vop(PL_op->op_type, TARG, left, right); @@ -1351,14 +1304,10 @@ PP(pp_bit_xor) { dPOPTOPssrl; if (SvNIOKp(left) || SvNIOKp(right)) { - if (PL_op->op_private & HINT_INTEGER) { - IBW value = (USE_LEFT(left) ? SvIV(left) : 0) ^ SvIV(right); - SETi(BWi(value)); - } - else { - UBW value = (USE_LEFT(left) ? SvUV(left) : 0) ^ SvUV(right); - SETu(BWu(value)); - } + if (PL_op->op_private & HINT_INTEGER) + SETi( (USE_LEFT(left) ? SvIV(left) : 0) ^ SvIV(right) ); + else + SETu( (USE_LEFT(left) ? SvUV(left) : 0) ^ SvUV(right) ); } else { do_vop(PL_op->op_type, TARG, left, right); @@ -1374,14 +1323,10 @@ PP(pp_bit_or) { dPOPTOPssrl; if (SvNIOKp(left) || SvNIOKp(right)) { - if (PL_op->op_private & HINT_INTEGER) { - IBW value = (USE_LEFT(left) ? SvIV(left) : 0) | SvIV(right); - SETi(BWi(value)); - } - else { - UBW value = (USE_LEFT(left) ? SvUV(left) : 0) | SvUV(right); - SETu(BWu(value)); - } + if (PL_op->op_private & HINT_INTEGER) + SETi( (USE_LEFT(left) ? SvIV(left) : 0) | SvIV(right) ); + else + SETu( (USE_LEFT(left) ? SvUV(left) : 0) | SvUV(right) ); } else { do_vop(PL_op->op_type, TARG, left, right); @@ -1440,14 +1385,10 @@ PP(pp_complement) { dTOPss; if (SvNIOKp(sv)) { - if (PL_op->op_private & HINT_INTEGER) { - IBW value = ~SvIV(sv); - SETi(BWi(value)); - } - else { - UBW value = ~SvUV(sv); - SETu(BWu(value)); - } + if (PL_op->op_private & HINT_INTEGER) + SETi( ~SvIV(sv) ); + else + SETu( ~SvUV(sv) ); } else { register char *tmps; |