[py-svn] r10584 - py/dist/py/c-extension/greenlet
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 13 18:33:38 CEST 2005
Author: arigo
Date: Wed Apr 13 18:33:38 2005
New Revision: 10584
Modified:
py/dist/py/c-extension/greenlet/greenlet.c
py/dist/py/c-extension/greenlet/greenlet.h
Log:
Bugfix. This makes greenlets work on OS X, apparently.
The problem was that a local variable 'int recursion_depth' was used to save
state across a switch, and it didn't work on OS X + gcc. Moved this saved
state into the PyGreenlet structure.
Modified: py/dist/py/c-extension/greenlet/greenlet.c
==============================================================================
--- py/dist/py/c-extension/greenlet/greenlet.c (original)
+++ py/dist/py/c-extension/greenlet/greenlet.c Wed Apr 13 18:33:38 2005
@@ -259,10 +259,10 @@
- ts_passaround: NULL if PyErr_Occurred(),
else a tuple of args sent to ts_target (holds a reference)
*/
- int err, recursion_depth;
+ int err;
{ /* save state */
PyThreadState* tstate = PyThreadState_GET();
- recursion_depth = tstate->recursion_depth;
+ ts_current->recursion_depth = tstate->recursion_depth;
ts_current->top_frame = tstate->frame;
}
ts_origin = ts_current;
@@ -273,7 +273,7 @@
}
else {
PyThreadState* tstate = PyThreadState_GET();
- tstate->recursion_depth = recursion_depth;
+ tstate->recursion_depth = ts_target->recursion_depth;
tstate->frame = ts_target->top_frame;
ts_target->top_frame = NULL;
ts_current = ts_target;
@@ -346,6 +346,8 @@
ts_target->stack_start = NULL;
ts_target->stack_stop = (char*) mark;
ts_target->stack_prev = ts_current;
+ ts_target->top_frame = NULL;
+ ts_target->recursion_depth = PyThreadState_GET()->recursion_depth;
err = _PyGreen_switchstack();
/* returns twice!
The 1st time with err=1: we are in the new greenlet
Modified: py/dist/py/c-extension/greenlet/greenlet.h
==============================================================================
--- py/dist/py/c-extension/greenlet/greenlet.h (original)
+++ py/dist/py/c-extension/greenlet/greenlet.h Wed Apr 13 18:33:38 2005
@@ -19,6 +19,7 @@
struct _greenlet* parent;
PyObject* run_info;
struct _frame* top_frame;
+ int recursion_depth;
} PyGreenlet;
extern PyTypeObject PyGreen_Type;
More information about the pytest-commit
mailing list