[pypy-svn] r73983 - in pypy/branch/cpython-extension/pypy/module/cpyext: . include

afa at codespeak.net afa at codespeak.net
Thu Apr 22 19:55:18 CEST 2010


Author: afa
Date: Thu Apr 22 19:55:17 2010
New Revision: 73983

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/include/pystate.h
   pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py
   pypy/branch/cpython-extension/pypy/module/cpyext/stubsactive.py
Log:
Provide stubs for many functions around PyThreadState and PyInterpreterState,
and move into pystate.py functions that are empty, but probably already right.


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/pystate.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/pystate.h	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/pystate.h	Thu Apr 22 19:55:17 2010
@@ -1,14 +1,17 @@
 #ifndef Py_PYSTATE_H
 #define Py_PYSTATE_H
 
-typedef struct _ts {
-    int initialized; // not used
-} PyThreadState;
+struct _ts; /* Forward */
+struct _is; /* Forward */
 
 typedef struct _is {
     int _foo;
 } PyInterpreterState;
 
+typedef struct _ts {
+    PyInterpreterState *interp;
+} PyThreadState;
+
 #define Py_BEGIN_ALLOW_THREADS { \
 			PyThreadState *_save; \
 			_save = PyEval_SaveThread();

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py	Thu Apr 22 19:55:17 2010
@@ -1,9 +1,10 @@
 from pypy.module.cpyext.api import cpython_api, generic_cpy_call, CANNOT_FAIL,\
-        cpython_struct, PyGILState_STATE
+        cpython_struct
 from pypy.rpython.lltypesystem import rffi, lltype
 
 
 PyThreadState = lltype.Ptr(cpython_struct("PyThreadState", ()))
+PyInterpreterState = lltype.Ptr(cpython_struct("PyInterpreterState", ()))
 
 @cpython_api([], PyThreadState, error=CANNOT_FAIL)
 def PyEval_SaveThread(space):
@@ -28,11 +29,12 @@
         from pypy.module.thread.gil import after_external_call
         after_external_call()
 
- at cpython_api([], PyGILState_STATE, error=CANNOT_FAIL)
-def PyGILState_Ensure(space):
-    return 0
-
- at cpython_api([PyGILState_STATE], lltype.Void)
-def PyGILState_Release(space, state):
+ at cpython_api([], lltype.Void)
+def PyEval_InitThreads(space):
     return
 
+ at cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
+def PyEval_ThreadsInitialized(space):
+    return 1
+
+

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/stubsactive.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/stubsactive.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/stubsactive.py	Thu Apr 22 19:55:17 2010
@@ -1,6 +1,8 @@
 from pypy.module.cpyext.pyobject import PyObject
-from pypy.module.cpyext.api import cpython_api, Py_ssize_t, CANNOT_FAIL
+from pypy.module.cpyext.api import cpython_api, Py_ssize_t, CANNOT_FAIL, CConfig
 from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.module.cpyext.pystate import PyThreadState, PyInterpreterState
+
 
 @cpython_api([PyObject], rffi.VOIDP, error=CANNOT_FAIL) #XXX
 def PyFile_AsFile(space, p):
@@ -44,3 +46,68 @@
     instead of the repr()."""
     raise NotImplementedError
 
+ at cpython_api([], lltype.Void)
+def PyErr_Print(space):
+    """Alias for PyErr_PrintEx(1)."""
+    raise NotImplementedError
+
+ at cpython_api([PyInterpreterState], PyThreadState, error=CANNOT_FAIL)
+def PyThreadState_New(space, interp):
+    """Create a new thread state object belonging to the given interpreter object.
+    The global interpreter lock need not be held, but may be held if it is
+    necessary to serialize calls to this function."""
+    raise NotImplementedError
+
+ at cpython_api([PyThreadState], lltype.Void)
+def PyThreadState_Clear(space, tstate):
+    """Reset all information in a thread state object.  The global interpreter lock
+    must be held."""
+    raise NotImplementedError
+
+ at cpython_api([PyThreadState], lltype.Void)
+def PyThreadState_Delete(space, tstate):
+    """Destroy a thread state object.  The global interpreter lock need not be held.
+    The thread state must have been reset with a previous call to
+    PyThreadState_Clear()."""
+    raise NotImplementedError
+
+ at cpython_api([PyThreadState], PyThreadState, error=CANNOT_FAIL)
+def PyThreadState_Swap(space, tstate):
+    """Swap the current thread state with the thread state given by the argument
+    tstate, which may be NULL.  The global interpreter lock must be held."""
+    raise NotImplementedError
+
+ at cpython_api([PyThreadState], lltype.Void)
+def PyEval_AcquireThread(space, tstate):
+    """Acquire the global interpreter lock and set the current thread state to
+    tstate, which should not be NULL.  The lock must have been created earlier.
+    If this thread already has the lock, deadlock ensues.  This function is not
+    available when thread support is disabled at compile time."""
+    raise NotImplementedError
+
+ at cpython_api([PyThreadState], lltype.Void)
+def PyEval_ReleaseThread(space, tstate):
+    """Reset the current thread state to NULL and release the global interpreter
+    lock.  The lock must have been created earlier and must be held by the current
+    thread.  The tstate argument, which must not be NULL, is only used to check
+    that it represents the current thread state --- if it isn't, a fatal error is
+    reported. This function is not available when thread support is disabled at
+    compile time."""
+    raise NotImplementedError
+
+ at cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
+def Py_MakePendingCalls(space):
+    return 0
+
+PyGILState_STATE = rffi.COpaquePtr('PyGILState_STATE',
+                                   typedef='PyGILState_STATE',
+                                   compilation_info=CConfig._compilation_info_)
+
+ at cpython_api([], PyGILState_STATE, error=CANNOT_FAIL)
+def PyGILState_Ensure(space):
+    return 0
+
+ at cpython_api([PyGILState_STATE], lltype.Void)
+def PyGILState_Release(space, state):
+    return
+



More information about the Pypy-commit mailing list