[pypy-commit] pypy default: cpyext: Add support for PyInterpreterState.next.
amauryfa
noreply at buildbot.pypy.org
Sat Jan 7 14:51:52 CET 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r51114:416009084c6f
Date: 2012-01-07 12:10 +0100
http://bitbucket.org/pypy/pypy/changeset/416009084c6f/
Log: cpyext: Add support for PyInterpreterState.next. Always NULL, since
there is only one interpreter...
diff --git a/pypy/module/cpyext/include/pystate.h b/pypy/module/cpyext/include/pystate.h
--- a/pypy/module/cpyext/include/pystate.h
+++ b/pypy/module/cpyext/include/pystate.h
@@ -5,7 +5,7 @@
struct _is; /* Forward */
typedef struct _is {
- int _foo;
+ struct _is *next;
} PyInterpreterState;
typedef struct _ts {
diff --git a/pypy/module/cpyext/pystate.py b/pypy/module/cpyext/pystate.py
--- a/pypy/module/cpyext/pystate.py
+++ b/pypy/module/cpyext/pystate.py
@@ -2,7 +2,10 @@
cpython_api, generic_cpy_call, CANNOT_FAIL, CConfig, cpython_struct)
from pypy.rpython.lltypesystem import rffi, lltype
-PyInterpreterState = lltype.Ptr(cpython_struct("PyInterpreterState", ()))
+PyInterpreterStateStruct = lltype.ForwardReference()
+PyInterpreterState = lltype.Ptr(PyInterpreterStateStruct)
+cpython_struct(
+ "PyInterpreterState", [('next', PyInterpreterState)], PyInterpreterStateStruct)
PyThreadState = lltype.Ptr(cpython_struct("PyThreadState", [('interp', PyInterpreterState)]))
@cpython_api([], PyThreadState, error=CANNOT_FAIL)
@@ -54,7 +57,8 @@
class InterpreterState(object):
def __init__(self, space):
- self.interpreter_state = lltype.malloc(PyInterpreterState.TO, flavor='raw', immortal=True)
+ self.interpreter_state = lltype.malloc(
+ PyInterpreterState.TO, flavor='raw', zero=True, immortal=True)
def new_thread_state(self):
capsule = ThreadStateCapsule()
diff --git a/pypy/module/cpyext/test/test_pystate.py b/pypy/module/cpyext/test/test_pystate.py
--- a/pypy/module/cpyext/test/test_pystate.py
+++ b/pypy/module/cpyext/test/test_pystate.py
@@ -37,6 +37,7 @@
def test_thread_state_interp(self, space, api):
ts = api.PyThreadState_Get()
assert ts.c_interp == api.PyInterpreterState_Head()
+ assert ts.c_interp.c_next == nullptr(PyInterpreterState.TO)
def test_basic_threadstate_dance(self, space, api):
# Let extension modules call these functions,
More information about the pypy-commit
mailing list