Incorrect right shift on 64-bit platforms.
Alex Cherepanov <[email protected]> Tue, 28 Jul 2009 12:14:12 -0400
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------030707010303020802030702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Fix incorrect right shift on 64-bit platforms. PLRM defines
bitshift operator as a logical shift. On 64-bit platform, the
integer operand was promoted to 64-bit long value, shifted,
and assigned back to 32-bit int, effectively emulating the sign
extension.
DIFFERENCES:
Progression in 26-02.PS on 64-bit platforms.
There's no other differences.
--------------030707010303020802030702
Content-Type: text/plain;
name="bitshift.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="bitshift.diff"
Index: gs/psi/zrelbit.c
===================================================================
--- gs/psi/zrelbit.c (revision 9871)
+++ gs/psi/zrelbit.c (working copy)
@@ -254,12 +254,10 @@
check_type(*op, t_integer);
check_type(op[-1], t_integer);
-#define MAX_SHIFT (arch_sizeof_long * 8 - 1)
- if (op->value.intval < -MAX_SHIFT || op->value.intval > MAX_SHIFT)
+ if (op->value.intval < -31 || op->value.intval > 31)
op[-1].value.intval = 0;
-#undef MAX_SHIFT
else if ((shift = op->value.intval) < 0)
- op[-1].value.intval = ((ulong)(op[-1].value.intval)) >> -shift;
+ op[-1].value.intval = ((uint)(op[-1].value.intval)) >> -shift;
else
op[-1].value.intval <<= shift;
pop(1);
--------------030707010303020802030702
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
--------------030707010303020802030702--