summaryrefslogtreecommitdiffstats
path: root/Python/ceval_gil.h
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ceval_gil.h')
-rw-r--r--Python/ceval_gil.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
index 34d48c9..99d576d 100644
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -180,15 +180,17 @@ drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate)
#endif
}
+/* Take the GIL.
+
+ The function saves errno at entry and restores its value at exit.
+
+ tstate must be non-NULL. */
static void
take_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate)
{
- if (tstate == NULL) {
- Py_FatalError("take_gil: NULL tstate");
- }
+ int err = errno;
struct _gil_runtime_state *gil = &ceval->gil;
- int err = errno;
MUTEX_LOCK(gil->mutex);
if (!_Py_atomic_load_relaxed(&gil->locked)) {
@@ -240,6 +242,7 @@ _ready:
}
MUTEX_UNLOCK(gil->mutex);
+
errno = err;
}