[Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.94,2.95
Tim Peters
tim_one@users.sourceforge.net
Wed, 05 Sep 2001 15:36:58 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv29981/python/Objects
Modified Files:
floatobject.c
Log Message:
Rework the way we try to check for libm overflow, given that C99 no longer
requires that errno ever get set, and it looks like glibc is already
playing that game. New rules:
+ Never use HUGE_VAL. Use the new Py_HUGE_VAL instead.
+ Never believe errno. If overflow is the only thing you're interested in,
use the new Py_OVERFLOWED(x) macro. If you're interested in any libm
errors, use the new Py_SET_ERANGE_IF_OVERFLOW(x) macro, which attempts
to set errno the way C89 said it worked.
Unfortunately, none of these are reliable, but they work on Windows and I
*expect* under glibc too.
Index: floatobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v
retrieving revision 2.94
retrieving revision 2.95
diff -C2 -d -r2.94 -r2.95
*** floatobject.c 2001/09/05 06:24:58 2.94
--- floatobject.c 2001/09/05 22:36:56 2.95
***************
*** 9,27 ****
#include <ctype.h>
- #ifdef i860
- /* Cray APP has bogus definition of HUGE_VAL in <math.h> */
- #undef HUGE_VAL
- #endif
-
- #if defined(HUGE_VAL) && !defined(CHECK)
- #define CHECK(x) if (errno != 0) ; \
- else if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \
- else errno = ERANGE
- #endif
-
- #ifndef CHECK
- #define CHECK(x) /* Don't know how to check */
- #endif
-
#if !defined(__STDC__) && !defined(macintosh)
extern double fmod(double, double);
--- 9,12 ----
***************
*** 536,540 ****
ix = pow(iv, iw);
PyFPE_END_PROTECT(ix)
! CHECK(ix);
if (errno != 0) {
/* XXX could it be another type of error? */
--- 521,525 ----
ix = pow(iv, iw);
PyFPE_END_PROTECT(ix)
! Py_SET_ERANGE_IF_OVERFLOW(ix);
if (errno != 0) {
/* XXX could it be another type of error? */