| Index: Include/ceval.h |
| =================================================================== |
| --- Include/ceval.h (revision 66050) |
| +++ Include/ceval.h (working copy) |
| @@ -46,22 +46,34 @@ |
| PyAPI_FUNC(void) Py_SetRecursionLimit(int); |
| PyAPI_FUNC(int) Py_GetRecursionLimit(void); |
| -#define Py_EnterRecursiveCall(where) \ |
| +#define Py_EnterRecursiveCall(where) \ |
| (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ |
| _Py_CheckRecursiveCall(where)) |
| #define Py_LeaveRecursiveCall() \ |
| - do{ if((--PyThreadState_GET()->recursion_depth) < \ |
| - _Py_CheckRecursionLimit - 50) \ |
| - PyThreadState_GET()->overflowed = 0; \ |
| - } while(0) |
| + do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \ |
| + PyThreadState_GET()->overflowed = 0; \ |
| + } while(0) |
| PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); |
| PyAPI_DATA(int) _Py_CheckRecursionLimit; |
| + |
| #ifdef USE_STACKCHECK |
| -# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit) |
| +/* With USE_STACKCHECK, we artificially decrement the recursion limit in order |
| + to trigger regular stack checks in _Py_CheckRecursiveCall(), except if |
| + the "overflowed" flag is set, in which case we need the true value |
| + of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly. |
| +*/ |
| +# define _Py_MakeRecCheck(x) \ |
| + (++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1)) |
| #else |
| # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) |
| #endif |
| +#ifdef USE_STACKCHECK |
| +# define _Py_MakeEndRecCheck(x) (--(x) < _Py_CheckRecursionLimit - 50) |
| +#else |
| +# define _Py_MakeEndRecCheck(x) (--(x) < _Py_CheckRecursionLimit - 50) |
| +#endif |
| + |
| #define Py_ALLOW_RECURSION \ |
| do { unsigned char _old = PyThreadState_GET()->recursion_critical;\ |
| PyThreadState_GET()->recursion_critical = 1; |