Skip to content

Commit

Permalink
Change PyFPE_END_PROTECT to PyFPE_END_PROTECT(v). v should be the
Browse files Browse the repository at this point in the history
last variable to which a floating point expression is assigned.  The
macro passes its address to a dummy function so that the optimizer
can't delay calculating its value until after the macro.
  • Loading branch information
gvanrossum committed Mar 14, 1997
1 parent efd3a3a commit 1f06bee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Include/pyfpe.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ extern "C" {
#include <math.h>
extern jmp_buf PyFPE_jbuf;
extern int PyFPE_counter;
extern double PyFPE_dummy(void);
extern double PyFPE_dummy();

#define PyFPE_START_PROTECT(err_string, leave_stmt) \
if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \
Expand All @@ -149,12 +149,12 @@ if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \
* which counts down PyFPE_counter, and thereby monkey wrench the overeager
* optimizer. Better solutions are welcomed....
*/
#define PyFPE_END_PROTECT PyFPE_counter -= (int)PyFPE_dummy();
#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v));

#else

#define PyFPE_START_PROTECT(err_string, leave_stmt)
#define PyFPE_END_PROTECT
#define PyFPE_END_PROTECT(v)

#endif

Expand Down

0 comments on commit 1f06bee

Please sign in to comment.