diff Python/ceval.c @ 5926:8d2194e22e67 legacy-trunk

The last of the mass checkins for separate (sub)interpreters. Everything should now work again. See the comments for the .h files mass checkin (e.g. pystate.h) for more detail.
author Guido van Rossum <guido@python.org>
date Sat, 02 Aug 1997 03:10:38 +0000
parents 6986781a07ef
children 5a4d181ffffd
line wrap: on
line diff
--- a/Python/ceval.c	Sat Aug 02 03:07:46 1997 +0000
+++ b/Python/ceval.c	Sat Aug 02 03:10:38 1997 +0000
@@ -130,6 +130,18 @@
 }
 
 void
+PyEval_AcquireLock()
+{
+	acquire_lock(interpreter_lock, 1);
+}
+
+void
+PyEval_ReleaseLock()
+{
+	release_lock(interpreter_lock);
+}
+
+void
 PyEval_AcquireThread(tstate)
 	PyThreadState *tstate;
 {
@@ -402,9 +414,6 @@
 
 /* Start of code */
 
-	if (tstate == NULL)
-		Py_FatalError("eval_code2 called without a current thread");
-
 #ifdef USE_STACKCHECK
 	if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) {
 		PyErr_SetString(PyExc_MemoryError, "Stack overflow");
@@ -590,7 +599,7 @@
 		   Py_MakePendingCalls() above. */
 		
 		if (things_to_do || --tstate->ticker < 0) {
-			tstate->ticker = tstate->sys_checkinterval;
+			tstate->ticker = tstate->interp->checkinterval;
 			if (things_to_do) {
 				if (Py_MakePendingCalls() < 0) {
 					why = WHY_EXCEPTION;
@@ -612,14 +621,15 @@
 			if (interpreter_lock) {
 				/* Give another thread a chance */
 
-				PyThreadState *tstate =
-					PyThreadState_Swap(NULL);
+				if (PyThreadState_Swap(NULL) != tstate)
+					Py_FatalError("ceval: tstate mix-up");
 				release_lock(interpreter_lock);
 
 				/* Other threads may run now */
 
 				acquire_lock(interpreter_lock, 1);
-				PyThreadState_Swap(tstate);
+				if (PyThreadState_Swap(tstate) != NULL)
+					Py_FatalError("ceval: orphan tstate");
 			}
 #endif
 		}
@@ -2176,9 +2186,10 @@
 PyObject *
 PyEval_GetBuiltins()
 {
-	PyFrameObject *current_frame = PyThreadState_Get()->frame;
+	PyThreadState *tstate = PyThreadState_Get();
+	PyFrameObject *current_frame = tstate->frame;
 	if (current_frame == NULL)
-		return PyBuiltin_GetModule();
+		return tstate->interp->builtins;
 	else
 		return current_frame->f_builtins;
 }