[Python-checkins] CVS: python/dist/src/Objects intobject.c,2.45,2.46 longobject.c,1.63,1.64
Tim Peters
python-dev@python.org
Fri, 7 Jul 2000 21:17:24 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv5529/src/Objects
Modified Files:
intobject.c longobject.c
Log Message:
Cray J90 fixes for long ints.
This was a convenient excuse to create the pyport.h file recently
discussed!
Please use new Py_ARITHMETIC_RIGHT_SHIFT when right-shifting a
signed int and you *need* sign-extension. This is #define'd in
pyport.h, keying off new config symbol SIGNED_RIGHT_SHIFT_ZERO_FILLS.
If you're running on a platform that needs that symbol #define'd,
the std tests never would have worked for you (in particular,
at least test_long would have failed).
The autoconfig stuff got added to Python after my Unix days, so
I don't know how that works. Would someone please look into doing
& testing an auto-config of the SIGNED_RIGHT_SHIFT_ZERO_FILLS
symbol? It needs to be defined if & only if, e.g., (-1) >> 3 is
not -1.
Index: intobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v
retrieving revision 2.45
retrieving revision 2.46
diff -C2 -r2.45 -r2.46
*** intobject.c 2000年06月30日 23:58:05 2.45
--- intobject.c 2000年07月08日 04:17:21 2.46
***************
*** 722,729 ****
}
else {
! if (a < 0)
! a = ~( ~(unsigned long)a >> b );
! else
! a = (unsigned long)a >> b;
}
return PyInt_FromLong(a);
--- 722,726 ----
}
else {
! a = Py_ARITHMETIC_RIGHT_SHIFT(long, a, b);
}
return PyInt_FromLong(a);
Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -r1.63 -r1.64
*** longobject.c 2000年07月08日 02:26:47 1.63
--- longobject.c 2000年07月08日 04:17:21 1.64
***************
*** 572,576 ****
int basebits = 1;
i = base;
! while ((i >>= 1) > 1) ++basebits;
i = 0;
--- 572,577 ----
int basebits = 1;
i = base;
! while ((i >>= 1) > 1)
! ++basebits;
i = 0;
***************
*** 854,858 ****
+ ((twodigits)zz << SHIFT);
v->ob_digit[i+k] = carry & MASK;
! carry = (carry >> SHIFT) - zz;
}
--- 855,861 ----
+ ((twodigits)zz << SHIFT);
v->ob_digit[i+k] = carry & MASK;
! carry = Py_ARITHMETIC_RIGHT_SHIFT(BASE_TWODIGITS_TYPE,
! carry, SHIFT);
! carry -= zz;
}
***************
*** 871,875 ****
carry += v->ob_digit[i+k] + w->ob_digit[i];
v->ob_digit[i+k] = carry & MASK;
! carry >>= SHIFT;
}
}
--- 874,880 ----
carry += v->ob_digit[i+k] + w->ob_digit[i];
v->ob_digit[i+k] = carry & MASK;
! carry = Py_ARITHMETIC_RIGHT_SHIFT(
! BASE_TWODIGITS_TYPE,
! carry, SHIFT);
}
}
***************
*** 989,994 ****
carry += a->ob_digit[i] + b->ob_digit[i];
z->ob_digit[i] = carry & MASK;
- /* The following assumes unsigned shifts don't
- propagate the sign bit. */
carry >>= SHIFT;
}
--- 994,997 ----