Index: Include/pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.54 diff -u -r2.54 pyport.h --- Include/pyport.h 15 Sep 2002 14:09:35 -0000 2.54 +++ Include/pyport.h 30 Nov 2002 22:28:26 -0000 @@ -256,9 +256,13 @@ * in non-overflow cases. * X is evaluated more than once. */ +#ifdef __FreeBSD__ +#define Py_OVERFLOWED(X) isinf(X) +#else #define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ (X) == Py_HUGE_VAL || \ (X) == -Py_HUGE_VAL)) +#endif /* Py_SET_ERANGE_ON_OVERFLOW(x) * If a libm function did not set errno, but it looks like the result Index: Objects/longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.145 diff -u -r1.145 longobject.c --- Objects/longobject.c 19 Nov 2002 20:49:15 -0000 1.145 +++ Objects/longobject.c 30 Nov 2002 22:28:47 -0000 @@ -8,6 +8,10 @@ #include +#ifdef __FreeBSD__ +# include +#endif + /* For long multiplication, use the O(N**2) school algorithm unless * both operands contain more than KARATSUBA_CUTOFF digits (this * being an internal Python long digit, in base BASE). @@ -563,6 +567,9 @@ { int e; double x; +#ifdef __FreeBSD__ + fp_except_t m; +#endif if (vv == NULL || !PyLong_Check(vv)) { PyErr_BadInternalCall(); @@ -574,7 +581,15 @@ if (e > INT_MAX / SHIFT) goto overflow; errno = 0; +#ifdef __FreeBSD__ + m=fpgetmask(); + fpsetmask(m&~FP_X_OFL); +#endif x = ldexp(x, e * SHIFT); +#ifdef __FreeBSD__ + fpresetsticky(FP_X_OFL); + fpsetmask(m); +#endif if (Py_OVERFLOWED(x)) goto overflow; return x; @@ -1984,6 +1999,9 @@ PyLongObject *a, *b; double ad, bd; int aexp, bexp, failed; +#ifdef __FreeBSD__ + fp_except_t m; +#endif CONVERT_BINOP(v, w, &a, &b); ad = _PyLong_AsScaledDouble((PyObject *)a, &aexp); @@ -2008,7 +2026,15 @@ else if (aexp < -(INT_MAX / SHIFT)) return PyFloat_FromDouble(0.0); /* underflow to 0 */ errno = 0; +#ifdef __FreeBSD__ + m=fpgetmask(); + fpsetmask(m&~FP_X_OFL); +#endif ad = ldexp(ad, aexp * SHIFT); +#ifdef __FreeBSD__ + fpresetsticky(FP_X_OFL); + fpsetmask(m); +#endif if (Py_OVERFLOWED(ad)) /* ignore underflow to 0.0 */ goto overflow; return PyFloat_FromDouble(ad);