diff Python/ceval.c @ 64628:56844b716cd7

remove gil_drop_request in --without-threads
author Benjamin Peterson <benjamin@python.org>
date Fri, 10 Sep 2010 22:47:02 +0000
parents 9265752a1c83
children e080f11fca19
line wrap: on
line diff
--- a/Python/ceval.c	Fri Sep 10 22:25:19 2010 +0000
+++ b/Python/ceval.c	Fri Sep 10 22:47:02 2010 +0000
@@ -217,16 +217,24 @@
 #endif
 
 
+#ifdef WITH_THREAD
+#define GIL_REQUEST _Py_atomic_load_relaxed(&gil_drop_request)
+#else
+#define GIL_REQUEST 0
+#endif
+
 /* This can set eval_breaker to 0 even though gil_drop_request became
    1.  We believe this is all right because the eval loop will release
    the GIL eventually anyway. */
 #define COMPUTE_EVAL_BREAKER() \
     _Py_atomic_store_relaxed( \
         &eval_breaker, \
-        _Py_atomic_load_relaxed(&gil_drop_request) | \
+        GIL_REQUEST | \
         _Py_atomic_load_relaxed(&pendingcalls_to_do) | \
         pending_async_exc)
 
+#ifdef WITH_THREAD
+
 #define SET_GIL_DROP_REQUEST() \
     do { \
         _Py_atomic_store_relaxed(&gil_drop_request, 1); \
@@ -239,6 +247,8 @@
         COMPUTE_EVAL_BREAKER(); \
     } while (0)
 
+#endif
+
 /* Pending calls are only modified under pending_lock */
 #define SIGNAL_PENDING_CALLS() \
     do { \
@@ -387,7 +397,6 @@
 
 #else
 static _Py_atomic_int eval_breaker = {0};
-static _Py_atomic_int gil_drop_request = {0};
 static int pending_async_exc = 0;
 #endif /* WITH_THREAD */
 
@@ -1277,8 +1286,8 @@
                     goto on_error;
                 }
             }
+#ifdef WITH_THREAD
             if (_Py_atomic_load_relaxed(&gil_drop_request)) {
-#ifdef WITH_THREAD
                 /* Give another thread a chance */
                 if (PyThreadState_Swap(NULL) != tstate)
                     Py_FatalError("ceval: tstate mix-up");
@@ -1289,8 +1298,8 @@
                 take_gil(tstate);
                 if (PyThreadState_Swap(tstate) != NULL)
                     Py_FatalError("ceval: orphan tstate");
+            }
 #endif
-            }
             /* Check for asynchronous exceptions. */
             if (tstate->async_exc != NULL) {
                 x = tstate->async_exc;